I sure hope this is an ok question to ask here. I realize it isn’t a specific programming Q, but hopefully it does have an answer.
I’ve been trying to learn Symfony (PHP framework) and I’ve gone through the Jobeet tutorial as well as read through the massive “Book”. So I sit here about to begin my first project and amazingly find myself absolutely stuck on what to do. I realized that after reading all that… that I didn’t “get” what the overall flow was. I’m asking this here because of the WIKI style so this can be adopted by experienced symfony users and melded into a final document that myself and other symfonewbies can use.
I’m beginning this from the point of view of a Windows user with a local server setup and the folder(s) containing php and symfony executables have been added to my PATH environment variable. I’m also using the assumption that Doctrine is being used rather than Propel as it has been stated in the docs that the default setup will be Doctrine going forward.
- Create a folder for your project. Open a command line (in Windows, Start -> cmd.exe) and use the generate:project command to make the skeleton.
- I’m really already lost here. From the Jobeet tutorial it seems to suggest the next step is creating your database in schema.yml and running doctrine:build-all? Or does generate:app and generate:module etc come first?
and so-on.
I’d appreciate any symfony pros out there contributing. Thanks.
Come up with a concept
First of all think of an interesting project that you would like to build. The default for this kind of project is usually a blog, but if that does not float your boat, how about something like a twitter clone or a reddit clone?
Build your model
In Symfony, the thing to do now is build your model. Create it in either a schema.YML file or in a graphical product like DB Designer, MySQL Workbench etc.
You need to add the tables, columns and foreign keys so that Propel can build you an interesting model to play with.
Let symfony build your apps
Now get on to the Symfony command line and create a couple of apps. A frontend, for the web and a backend to manage the site as an administrator.
Now let Symfony generate your model based on your schema. The lib/model folder should now have a load of files, filled with some useful functions based on your model.
For your backend app, generate a CRUD system with the admin generator and customise it with the yml file provided. Follow the myfirstapp tutorial for some interesting additions for the CRUD site.
Go in and edit your freshly built site!
For the Front end, create a module for each of the major parts of your site. These may include users, articles, tags, comments, stories, links, votes etc etc. Once you have some modules set up, the real fun starts. Create some functions in your actions file (such as list, show, delete, update) and create corresponding template files to display the results of the action.
Each action you create is automatically mapped to a corresponding URL.
Hope this gives you some inspiration!