1

I am in trouble to choose the right way to develop my application. My app will be quite complex and I would like it to be well architectured. I will have in fact 4 "applications" (adminAPI, clientAPI, frontWebsite, adminArea) and I want each of these "applications" to run on a different server in production.

So my first idea was to create 4 symfony projects. But I have to share a lot of code about entities, forms, validators, buisness logic.

So I see that I can create only one project with one different AppKernel per application. This sound good to me. Is it the right solution? If I go for it, should I create also one Bundle per AppKernel to keep things clean and one "CoreBundle" with shared classes like entities, forms, managers and handlers? Or it is better as said on Symfony Best Practices to keep all in one AppBundle?

As you see I'm a bit confused and I really need your help to create a professionnal application that will grow quickly. Thank you for your time.

ybert
  • 852
  • 10
  • 18
  • in this case, the idea of a dedicated bundle that contains all the shared thinks can be ok. You share the bundle between the other project as dependency in the composer.json (ad version as standalone project). So you have the 4 repos of your apps plus a corebundle repo that is included as dependency – Matteo Apr 22 '16 at 08:18
  • To be honest I think the framework you're using should be a decision you can make relatively late in the game. The core business logic of your application should be able to exist without any dependencies on any framework at all. You should only start thinking about frameworks for the housekeeping stuff (persistence, validation, user interface, etc). – GordonM Apr 22 '16 at 08:22
  • You may be interested in this old question: [Symfony2 conceptual issue: general bundles vs. specific ones](http://stackoverflow.com/a/8016867/2257664). – A.L Apr 22 '16 at 09:43
  • @A.L yes I saw this question before. But it is only about Bundle strategy in one application and not about multi applications strategy for one project. – ybert Apr 22 '16 at 09:51

2 Answers2

1

You must not create one project for each area of your application. With Symfony2 your are to create more than one development environment.

You can create for each of you area one bundle and just decide within the kernel witch bundle should be loaded depends on the environment you have chose.

  • ok it was what I thought. But if I do this I have to create config files for each environment right? And when I will deploy my app, I will deploy in 4 servers (one for each part of the app) the full code and redirect to the right frontend controller? – ybert Apr 22 '16 at 08:34
  • BlaBlaCar use this approach but don't scale too much, see this presentation about https://speakerdeck.com/odolbeau/symfony-at-blablacar?slide=26 – Matteo Apr 22 '16 at 08:37
  • No you do not have to deploy on 4 different servers, you have just to deploy on one server. You could just create like 4 vHost / nginx configuration. – David Keller Apr 22 '16 at 08:40
  • So @Matteo, you think it's better to create different projects if my app scales? What is bad with differnt AppKernels/FrontControllers? – ybert Apr 22 '16 at 08:53
  • 1
    Hi @ybert i comment your question regards your specific point requested. IMHO, for scale well is better a microservice approach check for available resources about symfony and microservice as example [this](http://www.slideshare.net/xfornesa/microservice-architecture) follow your problem and discuss about your approach incrementally – Matteo Apr 22 '16 at 08:59
0

I would create a "CoreBundle" with all the shared functionality and then use it in the 4 Symfony projects.

Dani Garval
  • 129
  • 6