Symfony 2: Console commands

The Symfony 2 console allows developers to execute commonly used tasks via the command line. This speeds up the development process since it allows a developer to execute many different tasks. These are e.g. creation of an Entity definition, creating the entire MVC folder structure, generating getters and setters and more.

Since there are so many of them I have added a quick reference list for myself below. I will expand the list with commands when I need them :-)

Symfony2 general

  • php app/console assets:install (install assets such ass css, js and images to web dir)
  • php app/console cache:clear --env=prod --no-debug (Clear cache on production machine)
  • php app/console doctrine:generate:entity (Creates a new entity)
  • php app/console doctrine:generate:entities YourBundle:Image (Generates getters and setters of an existing entity)
  • php app/console generate:doctrine:crud (create crud = create, read, update, delete controller) based on entity


  • php app/console doctrine:database:drop (Drops a comeplete database based on settings in config.yml)
  • php app/console doctrine:database:create (Creates an empty database with the name and credentials from your Symfony 2 config)
  • php app/console doctrine:schema:update --force (updates the database schema based on your entity definitions)


All commands above are by defult run on the Development environment. If you need to execute these commands on production then first backup your data and then add the following parameter after your command: --env=prod