Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by SensioLabs
  1. Home
  2. Documentation
  3. Cookbook
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

The Cookbook

Edit this page

Warning: You are browsing the documentation for Symfony 2.6, which is no longer maintained.

Read the updated version of this page for Symfony 6.3 (the current stable version).

The Cookbook

  • Assetic

    • How to Use Assetic for Asset Management
    • Combining, Compiling and Minimizing Web Assets with PHP Libraries
    • How to Minify CSS/JS Files (Using UglifyJS and UglifyCSS)
    • How to Minify JavaScripts and Stylesheets with YUI Compressor
    • How to Use Assetic for Image Optimization with Twig Functions
    • How to Apply an Assetic Filter to a specific File Extension
  • Bundles

    • How to Install 3rd Party Bundles
    • Best Practices for Reusable Bundles
    • How to Use Bundle Inheritance to Override Parts of a Bundle
    • How to Override any Part of a Bundle
    • How to Remove the AcmeDemoBundle
    • How to Load Service Configuration inside a Bundle
    • How to Create Friendly Configuration for a Bundle
    • How to Simplify Configuration of multiple Bundles
  • Cache

    • How to Use Varnish to Speed up my Website
    • Caching Pages that Contain CSRF Protected Forms
  • Composer

    • Installing Composer
  • Configuration

    • How to Master and Create new Environments
    • How to Override Symfony's default Directory Structure
    • Using Parameters within a Dependency Injection Class
    • Understanding how the Front Controller, Kernel and Environments Work together
    • How to Set external Parameters in the Service Container
    • How to Use PdoSessionHandler to Store Sessions in the Database
    • How to Use the Apache Router
    • Configuring a Web Server
    • How to Organize Configuration Files
    • How to Use MongoDbSessionHandler to Store Sessions in a MongoDB Database
  • Console

    • How to Create a Console Command
    • How to Use the Console
    • How to Call a Command from a Controller
    • How to Generate URLs and Send Emails from the Console
    • How to Enable Logging in Console Commands
    • How to Define Commands as Services
  • Controller

    • How to Customize Error Pages
    • How to Define Controllers as Services
    • How to Upload Files
  • Debugging

    • How to Optimize your Development Environment for Debugging
  • Deployment

    • How to Deploy a Symfony Application
    • Deploying to Microsoft Azure Website Cloud
    • Deploying to Heroku Cloud
    • Deploying to Platform.sh
  • Doctrine

    • How to Handle File Uploads with Doctrine
    • How to use Doctrine Extensions: Timestampable, Sluggable, Translatable, etc.
    • How to Register Event Listeners and Subscribers
    • How to Use Doctrine DBAL
    • How to Generate Entities from an Existing Database
    • How to Work with multiple Entity Managers and Connections
    • How to Register custom DQL Functions
    • How to Define Relationships with Abstract Classes and Interfaces
    • How to Provide Model Classes for several Doctrine Implementations
    • How to Implement a simple Registration Form
    • Console Commands
    • (configuration) How to Use PdoSessionHandler to Store Sessions in the Database
  • Email

    • How to Send an Email
    • How to Use Gmail to Send Emails
    • How to Use the Cloud to Send Emails
    • How to Work with Emails during Development
    • How to Spool Emails
    • How to Test that an Email is Sent in a Functional Test
  • Event Dispatcher

    • How to Setup before and after Filters
    • How to Extend a Class without Using Inheritance
    • How to Customize a Method Behavior without Using Inheritance
    • (service container) How to Create an Event Listener
  • Expressions

    • How to use Expressions in Security, Routing, Services, and Validation
  • Form

    • How to Customize Form Rendering
    • How to Use Data Transformers
    • How to Dynamically Modify Forms Using Form Events
    • How to Embed a Collection of Forms
    • How to Create a Custom Form Field Type
    • How to Create a Form Type Extension
    • How to Reduce Code Duplication with "inherit_data"
    • How to Unit Test your Forms
    • How to Configure empty Data for a Form Class
    • How to Use the submit() Function to Handle Form Submissions
    • (validation) How to Create a custom Validation Constraint
    • (doctrine) How to Handle File Uploads with Doctrine
  • Front-end

    • Using Bower with Symfony
  • Install and Upgrade

    • How to Install or Upgrade to the Latest, Unreleased Symfony Version
  • Logging

    • How to Use Monolog to Write Logs
    • How to Configure Monolog to Email Errors
    • How to Configure Monolog to Display Console Messages
    • How to Configure Monolog to Exclude 404 Errors from the Log
    • How to Log Messages to different Files
  • Profiler

    • How to Create a custom Data Collector
    • How to Use Matchers to Enable the Profiler Conditionally
    • Switching the Profiler Storage
    • How to Access Profiling Data Programmatically
  • Request

    • How to Configure Symfony to Work behind a Load Balancer or a Reverse Proxy
    • How to Register a new Request Format and Mime Type
    • (session) Making the Locale "Sticky" during a User's Session
  • Routing

    • How to Force Routes to always Use HTTPS or HTTP
    • How to Allow a "/" Character in a Route Parameter
    • How to Configure a Redirect without a custom Controller
    • How to Use HTTP Methods beyond GET and POST in Routes
    • How to Use Service Container Parameters in your Routes
    • How to Create a custom Route Loader
    • Redirect URLs with a Trailing Slash
    • How to Pass Extra Information from a Route to a Controller
  • Security Authentication (Identifying/Logging in the User)

    • How to Build a Traditional Login Form
    • How to Load Security Users from the Database (the Entity Provider)
    • How to Add "Remember Me" Login Functionality
    • How to Impersonate a User
    • How to Customize your Form Login
    • How to Create a custom User Provider
    • How to Create a Custom Form Password Authenticator
    • How to Authenticate Users with API Keys
    • How to Create a custom Authentication Provider
    • Using pre Authenticated Security Firewalls
    • How to Change the default Target Path Behavior
    • Using CSRF Protection in the Login Form
    • How to Choose the Password Encoder Algorithm Dynamically
    • How to Use multiple User Providers
    • How to Restrict Firewalls to a Specific Request
    • How to Restrict Firewalls to a Specific Host
  • Security Authorization (Denying Access)

    • How to Use Voters to Check User Permissions
    • How to Use Access Control Lists (ACLs)
    • How to Use advanced ACL Concepts
    • How to Force HTTPS or HTTP for different URLs
    • How to Secure any Service or Method in your Application
    • How Does the Security access_control Work?
  • Serializer

    • How to Use the Serializer
  • Service Container

    • How to Create an Event Listener
    • How to Work with Scopes
    • How to Work with Compiler Passes in Bundles
  • Sessions

    • Session Proxy Examples
    • Making the Locale "Sticky" during a User's Session
    • Configuring the Directory where Session Files are Saved
    • Bridge a legacy Application with Symfony Sessions
    • Limit Session Metadata Writes
    • (configuration) How to Use PdoSessionHandler to Store Sessions in the Database
    • (configuration) How to Use MongoDbSessionHandler to Store Sessions in a MongoDB Database
    • Avoid Starting Sessions for Anonymous Users
  • PSR-7

    • The PSR-7 Bridge
  • symfony1

    • How Symfony2 Differs from Symfony1
  • Templating

    • How to Inject Variables into all Templates (i.e. global Variables)
    • How to Use and Register Namespaced Twig Paths
    • How to Use PHP instead of Twig for Templates
    • How to Write a custom Twig Extension
    • How to Render a Template without a custom Controller
  • Testing

    • How to Simulate HTTP Authentication in a Functional Test
    • How to Simulate Authentication with a Token in a Functional Test
    • How to Test the Interaction of several Clients
    • How to Use the Profiler in a Functional Test
    • How to Test Code that Interacts with the Database
    • How to Test Doctrine Repositories
    • How to Customize the Bootstrap Process before Running Tests
    • (email) How to Test that an Email is Sent in a Functional Test
    • (form) How to Unit Test your Forms
  • Upgrading

    • Upgrading a Patch Version (e.g. 2.6.0 to 2.6.1)
    • Upgrading a Minor Version (e.g. 2.5.3 to 2.6.1)
    • Upgrading a Major Version (e.g. 2.7.0 to 3.0.0)
  • Validation

    • How to Create a custom Validation Constraint
    • How to Handle Different Error Levels
  • Web Server

    • How to Use PHP's built-in Web Server
    • (configuration) Configuring a Web Server
  • Web Services

    • How to Create a SOAP Web Service in a Symfony Controller
  • Workflow

    • How to Create and Store a Symfony Project in Git
    • How to Create and Store a Symfony Project in Subversion
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    Put the code quality back at the heart of your project

    Put the code quality back at the heart of your project

    Code consumes server resources. Blackfire tells you how

    Code consumes server resources. Blackfire tells you how

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of Reece Fowell, a Symfony contributor

    Thanks Reece Fowell (@reecefowell) for being a Symfony contributor

    1 commit • 633 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Deployed on

    Follow Symfony

    Search by Meilisearch