I have the exact question that this guy has: http://groups.google.com/group/symfony2/browse_thread/thread/cd35132cc6972f29
I'll just copy-paste it here:
I was wondering what different ways of organizing bundles within a project people are using.
I seem to end up with either one massive bundle for a project or a lot of bundles which are closely related (dependant) to each other. eg;
I implemented my own user entity and login forms etc, but the users are linked to an organization (with some functionality). Etc ... It's mostly the entities that overlap a lot I guess ...
Do you guys split them up or dump them all in the same bundle?
A Symfony bundle is a collection of files and folders organized in a specific structure. The bundles are modeled in such a way that it can be reused in multiple applications. The main application itself is packaged as a bundle and it is generally called AppBundle.
A bundle can be considered essentially a plugin for a Symfony project; it can wrap any functionality found in a Symfony application including configuration, controllers, routes, services, event listeners, templates, etc.
Edit: I don't use bundles for app-specific code anymore.
Personally I prefer to have a bundle per a section of an application. For example:
This is okay if the app is a mishmash of several functionalities, none of which is big enough to require a separate application and/or a subdomain. But if I was developing a big webstore applicaton, my bundles would be more specific:
So, I'd say, it depends on the focus of the project. What's just a section for one project could be the core functionality of another.
And I usually have CommonBundle, where all the common stuff goes, like global CSS, images, layouts, etc.
Also there are at least two options for the backend organization:
Personally I lean towards the first option and you can read about it in my previous answer, but there are people who prefer to have a separate bundle for the whole backend — probably using one of the admin bundles.
By the way, it's perfectly okay for bundles to be interconnected — you don't have to make them all independent of each other. For example, JMSDiExtraBundle depends on the metadata library and JMSAopBundle, which in turn depends on cg-library. If you'll try to keep bundles totally independent, you'll end up with big monolithic one-bundle lumps of code.
For every project I start off with one CoreBundle, where I put everything together. Then I just develop features in it and as time goes I reevaluate it - if I might use this feature somewhere else someday (or even release to open source), I move it to a new bundle.
"Size" of the feature worth separate bundle doesn't really matter - I've seen OS bundles as big as a 1 single js file :D
One thing for sure - stuffing everything in a single bundle is bad, it goes against the whole reason why this architecture was implemented in the first place!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With