Symfony — CLI and bin/console for Symfony Projects
Practical guide to Symfony: the CLI for the local server and bin/console for make, Doctrine, cache, routing and debugging your Symfony apps.
Symfony is one of the leading PHP frameworks for web applications and APIs. Day to day you work with two tools: the separate symfony CLI (the Symfony binary) starts the local development server, scaffolds new projects and bundles tooling around Symfony Cloud. For everything inside your application – code generation, database migrations, cache, routing and debugging – you use php bin/console, the framework's Console component. This guide collects the commands you reach for most often in everyday project work.
General
php bin/console list — List all available commands.
php bin/console listphp bin/console help <command> — Show help for a specific command.
php bin/console help make:entityphp bin/console about — Show information about the current project.
php bin/console aboutsymfony serve — Start the Symfony local web server.
symfony serve -dsymfony new <name> — Create a new Symfony project.
symfony new my-project --webappCode Generation (make:)
php bin/console make:entity — Create or update a Doctrine entity class.
php bin/console make:entity Productphp bin/console make:controller — Create a new controller class.
php bin/console make:controller ProductControllerphp bin/console make:form — Create a new form type class.
php bin/console make:form ProductTypephp bin/console make:migration — Generate a migration based on entity changes.
php bin/console make:migrationphp bin/console make:command — Create a new console command class.
php bin/console make:command app:send-emailsphp bin/console make:subscriber — Create a new event subscriber class.
php bin/console make:subscriber ExceptionSubscriberphp bin/console make:twig-extension — Create a Twig extension.
php bin/console make:twig-extension AppExtensionphp bin/console make:voter — Create a new security voter.
php bin/console make:voter ProductVoterDatabase & Doctrine
php bin/console doctrine:database:create — Create the configured database.
php bin/console doctrine:database:createphp bin/console doctrine:migrations:migrate — Run pending database migrations.
php bin/console doctrine:migrations:migratephp bin/console doctrine:migrations:status — Show migration status.
php bin/console doctrine:migrations:statusphp bin/console doctrine:schema:validate — Validate the mapping files and database schema.
php bin/console doctrine:schema:validatephp bin/console doctrine:schema:update --dump-sql — Show SQL needed to update database schema.
php bin/console doctrine:schema:update --dump-sqlphp bin/console doctrine:fixtures:load — Load data fixtures into the database.
php bin/console doctrine:fixtures:load --appendphp bin/console dbal:run-sql '<sql>' — Execute raw SQL directly.
php bin/console dbal:run-sql 'SELECT count(*) FROM product'Cache & Config
php bin/console cache:clear — Clear the application cache.
php bin/console cache:clearphp bin/console cache:warmup — Warm up the cache.
php bin/console cache:warmupphp bin/console cache:pool:clear <pool> — Clear a specific cache pool.
php bin/console cache:pool:clear cache.appphp bin/console debug:config <bundle> — Show resolved configuration for a bundle.
php bin/console debug:config frameworkphp bin/console config:dump-reference <bundle> — Show full default configuration reference.
php bin/console config:dump-reference securityDebug & Routes
php bin/console debug:router — List all registered routes.
php bin/console debug:routerphp bin/console debug:router <name> — Show details of a specific route.
php bin/console debug:router app_product_showphp bin/console router:match <path> — Show which route matches a given URL path.
php bin/console router:match /product/42php bin/console debug:container — List all services in the container.
php bin/console debug:container --show-argumentsphp bin/console debug:container <service> — Show details of a specific service.
php bin/console debug:container App\Service\Mailerphp bin/console debug:event-dispatcher — List all registered event listeners.
php bin/console debug:event-dispatcher kernel.requestphp bin/console debug:twig — Show Twig functions, filters, and globals.
php bin/console debug:twigMessenger & Security
php bin/console messenger:consume <transport> — Consume messages from a transport (queue worker).
php bin/console messenger:consume async --limit=10php bin/console messenger:failed:show — Show failed messages.
php bin/console messenger:failed:showphp bin/console messenger:failed:retry — Retry failed messages.
php bin/console messenger:failed:retryphp bin/console security:hash-password — Hash a plain-text password.
php bin/console security:hash-passwordphp bin/console secrets:set <name> — Set a secret in the vault.
php bin/console secrets:set DATABASE_PASSWORD Conclusion
Between the symfony CLI and bin/console you have nearly everything a Symfony project needs day to day – from the local server to code generation, cache and routing. The local server (symfony serve) is meant for development only; in production your app runs behind a real web server such as nginx or Apache with PHP-FPM. Be careful with data-changing Doctrine commands: doctrine:migrations:migrate along with doctrine:database:drop and doctrine:schema:drop can delete data irreversibly – take a backup first and use --no-interaction in production only deliberately and after review. cache:clear is harmless, but in production it should run in the correct environment. The console is extensible: with make:command you build your own commands in the same style.
Further Reading
- Symfony Documentation – official reference for the framework, console and components
- The Console Component – details on
bin/consoleand custom commands - Symfony Local Web Server – setup and usage of the
symfonyCLI