php bin/console list
Browse / Symfony Cheat Sheet
Symfony Cheat Sheet
A quick reference guide for Symfony, covering essential concepts, commands, and configurations.
Basic Commands
Console Commands
|
|
Lists all available console commands. |
|
|
Displays help for a specific command. |
|
|
Generates a new controller. |
|
|
Creates a new entity. |
|
|
Executes pending database migrations. |
|
|
Clears the application cache. |
|
|
Starts the built-in PHP web server. |
|
|
Lists all defined routes. |
Environment Variables
|
Environment variables are defined in Example:
|
|
In your code:
|
Routing
Route Annotations
|
Example of using annotations for routing in a controller:
|
Route Parameters
|
Required Parameter |
|
|
Optional Parameter |
|
|
Parameter with Requirements |
|
Generating URLs
|
Generating URLs in your code:
|
Controllers and Views
Controller Basics
|
A simple controller example:
|
Passing Data to Templates
|
Example of passing data to a Twig template:
|
Services and Dependency Injection
Defining Services
|
Services are typically defined in
|
Using Services
|
In a Controller: |
|
|
Autowiring |
Symfony automatically injects services based on type hints. |
Service Tags
|
Example of tagging a service:
|