0

Should I create new bundle and use sepparate assets for admin page, or could I just create new adminAction() as page? What would be safer and more correct?

I am not familiar to Symfony2 web structure and want to get better at it. Thanks in advance :)

Ignas Damunskis
  • 1,515
  • 1
  • 17
  • 44

2 Answers2

0

It depends on your application and there is no "Only one good way". Try to comply SOLID principles and all will be great.

Making many bundles - very bad idea (if you will not reuse your admin-bundle in other projects). You can find info about that in official symfony best-practices

Michael Sivolobov
  • 12,388
  • 3
  • 43
  • 64
0

I have only done a bit of Symfony 2 but the vast majority of project I have seen are using separate bundle for the Admin backend, such as the sonata project

It provides a better separation of concerns, as backend actions are oftenly related to CRUD, when frontend are usually more displays and users managements stuffs (depending on the goal of your project though).

To go further you can also already find bundle similar to the admin backend generator module of symfony (v1), like the symfony2admingenerator

Hope it helped a little.

Balessan
  • 2,456
  • 2
  • 12
  • 20
  • So I should create new bundle like `AdminBundle`, right? And create view and and functionality in that bundle for admin page? – Ignas Damunskis Oct 27 '14 at 15:06
  • Not. As said in symfony official best practices you don't need separate bundle for all your stuff. You need to add new bundle only if you will have absolutely the same bundle inside another project (in most cases it will be located in `vendors` dir) – Michael Sivolobov Oct 28 '14 at 07:42
  • @MichaelSivolobov Do you have any links for those official Symfony best practices ? – Balessan Oct 28 '14 at 08:26
  • Ok thanks ;-) I found some resources there on SO on this topic, such as http://stackoverflow.com/questions/8012191/symfony2-conceptual-issue-general-bundles-vs-specific-ones or http://stackoverflow.com/questions/10025278/symfony2-bundles-am-i-using-them-right or http://symfony.com/doc/current/cookbook/bundles/best_practices.html but it still depends on the scope of the project. As it is said there, people seems usually to go with separate bundles, and seems to come back from this approach later on. – Balessan Oct 28 '14 at 08:34
  • And both answers on your links for approach to use one `AppBundle`. It is the best way. Don't complicate simple tasks. – Michael Sivolobov Oct 28 '14 at 08:47