-1

I'm developing a website which has a public part and a backoffice part. My intention is to have this bundle structure:

  • Acme/CoreBundle: common entities, repositories, services for both public and private
  • Acme/BackofficeBundle: controllers, forms, url... etc of the backoffice
  • Acme/FrontofficeBundle: same for the frontoffice

Then modify the app_kernel so the bundles of one or the other would be load depending on a enviroment variable of the virtual host.

Does this make sense or there is a better approach for this?

Thanks!

petekaner
  • 8,071
  • 5
  • 29
  • 52
  • 1
    Your question is primarily opinion-based. You should avoid asking questions like this on SO. Read help http://stackoverflow.com/help/dont-ask. – Michael Sivolobov Mar 05 '15 at 18:20
  • Hi Michael, I really don't know to put it. Im not really asking for opinions but if I'm doing this correctly or there is another "standard" way for this approach. How can I ask the question then? – petekaner Mar 05 '15 at 19:29
  • You would be better off just using security.yml to secure the backoffice routes so they are only accessible by IP addresses on your internal network. Then leave the public ones open to the world. Conditional loading bundles and their assets based on environment gets to be a huge hassle. – Chase Mar 05 '15 at 19:36
  • I'll second Michael. [Programmers](http://programmers.stackexchange.com/) is more suited to discuss concepts – Tom Tom Mar 06 '15 at 17:46
  • thank you, i didn't knew programmers – petekaner Mar 07 '15 at 11:50

1 Answers1

0

I think you should go with a different approach than the one you presented. You don't need to make this clear difference between backend and frontend. You should organize your code using other criterias than "frontend vs backend".

Let's say you have a shopping cart. So you might need some order, customer and product administration. You will have a frontend and a backend. I think the best practice in this case is, if you take the orders, to create an Acme\OrderBundle. Here you will keep everything that is order related. You can keep the frontend controllers in Controller/ and backend controllers in Controller/Backend/. You can create some services for backend area and keep them in Acme\OrderBundle\Backend, but generally your services/forms/etc. should not know about where are they used on, frontend or backend. The controllers should be used to make this distinction. This way you can create a service for order administration that is used on frontend and also on backend, forms that can be used on both ends etc.

Alexandru Furculita
  • 1,374
  • 9
  • 19
  • Sounds reasonable, although I find some problems with this approach. For example, what if in both backend and frontend I need the same url. For example /your-account for the user settings (and backend and frontend use different users) – petekaner Mar 05 '15 at 21:51
  • You can prefix all the backend routes with /admin/ or /backend/. symfony.com/doc/current/book/routing.html#prefixing-imported-routes – Alexandru Furculita Mar 05 '15 at 21:55
  • I know, but I don't want to prefix them. It wouldn't very "elegant". The backend is planned to be in a different domain: backend.acme.com/your-account and www.acme.com/your-account – petekaner Mar 06 '15 at 07:24
  • In this case, you can use host matching for the imported files: http://symfony.com/doc/current/components/routing/hostname_pattern.html#using-host-matching-of-imported-routes – Alexandru Furculita Mar 06 '15 at 12:01