My Favorite Symfony Console Commands
About
Displays info about the current project. I use this command to check the version of symfony being used, the version of PHP being used, and whether or not Xdebug is enabled. I check Xdebug because when it is enabled, composer performance is greatly affected.
assetic:dump
Compiles and moves all assets managed by assetic (images, CSS, JS) to the filesystem. In my case, it compiles my LESS into CSS and moves it to the filesystem. I also use assetic to manage my JS files.
assetic:watch
Compiles and moves all assets managed by assetic (images, CSS, JS) to the filesystem as they are modified. I generally always have this command running when actively working in a LESS or JS file.
cache:clear
Clears the cache. This is particularly helpful and necessary when deploying changes to a Symfony production environment.
debug:router
Lists all available routes in the application. I use this to easily find a route name when generating a URL in a template or a controller.
doctrine:database:create
Creates a database using the default connection’s name. I use this command to initialize a database for my projects.
doctrine:generate:crud
Generates the create, read, update, and delete methods for a specified entity. I pretty much use this command for all of my entities as it is a huge time saver.
doctrine:generate:entities
Generates entity classes with attributes and methods bases on your database mapping information. I never manually create any class that maps to the database; I always create the database mapping first and use this console command to generate the entity class for me. This is a huge time saver.
doctrine:schema:update
Synchronize the database schema with the current mapping information. I use this command to quickly bring my database up to sync when, for instance, I add or remove an attribute from an entity. This command should only be used in pre-production versions of your app. For production environments, Doctrine Migrations should be used to change the database schema.
fos:user:change-password
Change the password of a user. I use this command to quickly change the password of a user for testing purposes.
fos:user:demote
Remove a role from a user. This command is extremely helpful when testing user permissions.
fos:user:promote
Add a role to a user. This command is extremely helpful when testing user permissions.
generate:bundle
Generates a new bundle. This command allows for quickly generating new bundles. I like it because it is interactive and therefore it is much less likely that I will forget a step when creating a new bundle. It can even register the new bundle in the AppKernel for you.
________________________ Endertech is a Los Angeles Software Development Company. Read more about our work with Symfony. Contact us if you would like a free consultation.