Saturday, November 11, 2017

Symfony Console Cheatsheet

Here are some useful console commands:

Automatically generate getter/setter methods in entities:
$ php bin/console doctrine:generate:entities AppBundle

Automatically generate getter/setter methods for specific table:
$ php bin/console doctrine:generate:entities AppBundle:"TABLE_NAME"

This functionality is deprecated and will result in following message. However maker bundle does not seem to work without config file with symfony 3.4

 NOTE: The doctrine:generate:entities command has been deprecated.
       To read more about the differences between anemic and rich models go here http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html#adding-behavior-to-entities.
       If you wish to generate your entities, use make:entity --regenerate from MakerBundle instead.



Create an entity and repository:
$ php bin/console generate:doctrine:entity --no-interaction --entity=AppBundle:Store/Product

Create/Update tables based on entities. Can use --dump-sql instead of --force to see the proposed commands.
$ php bin/console doctrine:schema:update --force

No comments:

Post a Comment