A checklist for adding a new app or module to a project built with the Symfony framework
One frustration I’ve had while learning Symfony is that there is no checklist regarding how to add a module or an app to a project. Though Symfony has a great book about itself, the information is not arranged in an easy-to-look-up format. Adding in a new module, to a new app, is, I think, a 7 step process:
1.) generate the schema file
2.) create the app
3.) create the module
4.) generate the model code
5.) generate the form code
6.) generate the CRUD files
7.) clear the cache
The commands for doing this are scattered all over the book. The form command is the worst - it is hidden on a page that has nothing to do with forms. So I’ve made a list and I’m posting it to my weblog, so that I and others can refer back to it.
1.) On this page is info about editing the schema file.
2.) On this page this command is shown to create an app:
php symfony generate:app frontend
3.) On this page this command is shown to generate a module (this module is being created as part of the app called “frontend”):
php symfony generate:module frontend content
It took me a long time to discover what the intended difference was between an app and a module. The answer I finally got is that most projects will have two apps: a front end that the public can see, and then a backend for administrators. Modules are the apps that make up one “app”.
4.) On this page this command is shown to build the model:
php symfony propel:build-model
5.) On this page this command is shown to build the form classes:
symfony propel:build-forms
6.) On this page I found this command which generates a CRUD module based on a Propel object model class:
symfony propel:generate-crud frontend author Author
7.) On this page I found the command for clearing the cache:
php symfony cc
If you don’t clear the cache, you often can’t see the changes you’ve made.
Since I work freelance, hours that I can’t bill for are expensive. In that sense, it has cost me several hundred dollars to learn Symfony. In theory it’ll pay off later, when I’m able to build new systems that much more quickly. I hope this little list saves other freelancers some time.