I'm involved in building a number of Symfony 2 applications, many of which
will need to share similar admin functionality based on the Sonata Admin
bundle. Of course, I don't want to copy and paste code between projects. :)
Suppose I have a bundle src/Acme/AdminBundle that provides the following:
* Log in/out (using entities in
* Administer users and groups (using entities in
* Administer Feature X (using entities in
* Administer Feature Y (using entities in
If Feature X and Feature Y both have several admin pages, and could be used
by several different web applications, I might be tempted to create the
* src/Acme/AdminBundle - base admin bundle including the user/group
admin, default dashboard and log in/out
* src/Acme/FeatureXAdminBundle - bundle that adds admin pages for
* src/Acme/FeatureYAdminBundle - bundle that adds admin pages for
The idea is that any application could bring in the admin bundles needed,
with the appropriate entries in config.yml.
So my questions are:
1. Is the above possible using Symfony 2 / Sonata Admin?
2. Is it a desirable approach anyway?
3. Is there an alternative way to provide this flexibility?
I've tried putting the above into practice, but it seems the closest I can
get involves having one 'main' AdminBundle with a config/services.yml
defining services with reference to all the other Admin bundles. Also
tried, unsuccessfully so far, to use bundle inheritance.