I would rather that Symfony had chosen a quick folder hierarchy, but they didn't. They chose the most hierarchical convoluted structure that they could think of and then added a few extra directories. Actually, it works quite well in terms of how component-agnostic (and multi-component-friendly) it is.

However, today I had the opportunity to explain it to someone for the first time and hence I finally understood it for the first time.

This is what I deemed to be of particular importance:
lib/model/doctrine/CamelClassName.class.php
~/Code/project_name
lib/model/doctrine/CamelClassNameTable.class.php
lib/model/doctrine/base/BaseCamelClassName.class.php
app/frontend/modules/lower_class_name/actions/actions.class.php
app/frontend/modules/lower_class_name/templates/indexSuccess.php
models
controllers
views
/var/www/project_name


lib/model/doctrine/CamelClassName.class.php

This represents the extension of one object in your database table. This is where you put your calculated values and temporary variables for any logic that belongs to the object itself.

lib/model/doctrine/CamelClassNameTable.class.php

This represents the table. This is where you create your NoSQL statements with joins and such using the Doctrine syntax.

lib/model/doctrine/base/BaseCamelClassName.class.php

This represents the class of one object. This maps the object to the database. You don't edit this, you edit the extension above.

app/frontend/modules/lower_class_name/actions/actions.class.php

If you visit http://www.example.com/lower_controller_name/action it will call the method executeAction here.

app/frontend/modules/lower_class_name/templates/indexSuccess.php

This represents the html template that you action calls.

models, controllers, views

Symlinks that I create to lib/model/doctrine/, app/frontend/modules/lower_class_name/actions and app/frontend/modules/lower_class_name/templates/ so that I know what the heck it is I'm doing and don't have to thumb through a billion directories... except I don't actually do that... but if I ever get heavy into symfony I may very well create a script that does... ugh, then there's the filter and forms and such too...

/var/www/project_name

This is a link to ~/Code/project_name/web, and is where you put your static files - images, css, and such.

Ruby has a much cleaner directory structure... but I don't think it's as easy to do complex things in Rails as it is in Symfony.

By AJ ONeal

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )