Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • SensioLabs Professional services to help you with Symfony
    • 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
    • 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.4, which is no longer maintained.

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

The Cookbook

  • Assetic

    • How to Use Assetic for Asset Management
    • 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
    • How to Use best Practices for Structuring 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
  • 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
  • Console

    • How to Create a Console Command
    • How to Use the Console
    • 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
  • 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
  • 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's DBAL Layer
    • 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
  • 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
  • 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
  • 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

    • 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 Implement your own Voter to Blacklist IP Addresses
    • 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 Restrict Firewalls to a Specific Request
    • How to Customize your Form Login
    • How to Secure any Service or Method in your Application
    • 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
  • 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
  • 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
  • Validation

    • How to Create a custom Validation Constraint
  • 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:
    Take the exam at home

    Take the exam at home

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Symfony footer

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

    Avatar of Marc Biorklund, a Symfony contributor

    Thanks Marc Biorklund for being a Symfony contributor

    2 commits • 18 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 Algolia