Using Symfony2 for one of my structure. I wanted to keep modules and the various files related to modules abstract from other module files.
So for eg. I have frontend application. Under frontend application I have users, gallery modules. I want to keep all the files related to users in one place and all the files related to gallery in one place. This way I achieve the abstraction at module level the way it is provided in Symfony1.4.
Following is the folder structure I achieved till here.
web/
admin.php
frontend.php
apps/
autoload.php # this autloads the common libaries/vendors for all application eg. CommonBundle
admin/
AppKernel.php
AppAutoload.php # load application specific libraries
bootstrap.php.cache
config/
cache/
.
.
.
frontend/
AppKernel.php
AppAutoload.php
bootstrap.php.cache
config/
cache/
.
.
.
src/
Admin/
UserBundle/
Controller/
UsersController.php
Entity/
User.php
Repository/
UserRepository.php
Resources/
views/
indexUserView.twig.html
DiaryBundle/
Controller/
DiaryController.php
Entity/
Diary.php
Repository/
DiaryRepository.php
Resources/
views/
indexDiaryView.twig.html
Frontend/
UserBundle/
Controller/
UsersController.php
Entity/
User.php
Repository/
UserRepository.php
Resources/
views/
indexUserView.twig.html
DiaryBundle/
Controller/
DiaryController.php
Entity/
Diary.php
Repository/
DiaryRepository.php
Resources/
views/
indexDiaryView.twig.html
I am confident about my above folder structure. But as I found Symfony2 community supporting creation of Bundle's at Application level and not at module level, I wanted to know the pros and cons of creating Bundles at module level. What can be the possible pit falls of creation at module level?
I can see many advantages of having Bundles for modules
All the Controller, Views, Models of a module are at same place and abstract from Controller, Models, Views of other modules. This way person working on one module has to work inside one folder only and not bother about person's work going on in module2 i.e Bundle2
Clear cache can happen at the application level using below command clear cache for just frontend application
shell> php apps/frontend/console cache:clear
If you need to create a bundle in frontend application, command is below. It creates UserBundle under src/frontend application. It also register the bundle name inside apps/frontend/AppKernel.php.
shell> php apps/frontend/console generate:bundle --namespace=frontend/userBundle --format=yml
so everything seems fine. But it seems Symfony2 community does not think this approach to be correct?
Please suggest loop holes in my approach?