It is not recommended to create separate FrontendBundle and BackendBundle as general bundles without controllers. Instead, bundles should encompass both front-end and back-end functionality as needed.
While it may seem logical to put layouts in bundles, it is best practice to keep them in the app/Resources/views/ directory. This allows for a clear separation of concerns and facilitates template inheritance across bundles.
Creating dedicated bundles for common functionalities like pagination and date display is a good practice. However, it can lead to excessive bundle proliferation.
Consider using a CommonBundle to store code that is shared by multiple bundles. This helps avoid duplication and promotes code modularity. However, be mindful of the potential for interdependencies between app-specific bundles.
In recent times, a newer approach has emerged where developers use a single app-specific bundle named AppBundle. This simplifies bundle management, reduces decision-making complexity, and eliminates the need for dedicated bundles for common functionalities.
The above is the detailed content of When Should You Use Bundles vs. Other Options for Symfony2?. For more information, please follow other related articles on the PHP Chinese website!