3

We have a project broken in two parts - API and Frontend.
Both are written in Symfony 3.4 and both are in different servers as well as git repositories.
As you may already know, Symfony uses bundles, with every bundle having it's own Entities.
Both of our project use the same Entities from bundles, plus the frontend one has extras.

At the moment, to maintain the entities it's somewhat hard since every change we do in one of the Entities must be aligned with the other project's entities.

I was thinking to use submodules feature from git to keep them both up-to-date, but then, what about the other folders inside the bundles? Like Services and Controllers? I just want to keep track of Entities so when we make a change both projects (or whoever) will be able to have those without us, having to copy-paste stuff.

What are you thinking and what are you suggesting?

Here's an example of the structure. I hope it's readable


Project A          Project B
-Bundle 1          -Bundle 1
---Entities        --- Entities

-Bundle 2          -Bundle 2
---Entities        ---Entities
---Services

-Bundle 3          -Bundle 3
---Entities        ---Entities
                   ---Services

                   -Bundle 4
Machavity
  • 30,841
  • 27
  • 92
  • 100
tsompanis
  • 324
  • 1
  • 3
  • 15
  • Pleas, do not downvote unless you state why you did it. Thank you very much. – tsompanis Mar 28 '18 at 10:46
  • 2
    A workaround could be multi-kernels approach https://github.com/yceruto/symfony-skeleton-vkernel – yceruto Mar 28 '18 at 11:15
  • 2
    One thing to consider is that entities do not have to be in a Symfony bundle. They can be off in their own little shared package and you can then configure your entity managers to use them. And as far as your down vote request, I'd suggest staying away from oceans as you may find yourself trying to stop the tide from coming in. – Cerad Mar 28 '18 at 12:41

2 Answers2

2

There is some options, you could use you're API to get data on your Frontend meaning you would only need your entities in yourAPI bundle.

Or you could have your entities in a third project being only one bundle with entities. Bundle that you would add to the two other projects with Composer

https://knpuniversity.com/screencast/question-answer-day/create-composer-package

Gregoire Ducharme
  • 1,095
  • 12
  • 24
  • Yep, the way it's to make the calls to API and the API to be able to communicate with Entities. But some times it's faster not make the call and have the Frontend handle some Entities too. I was thinking about the composer, but wouldnt that mean i have to extend the Bundles from vendor ? – tsompanis Mar 28 '18 at 10:44
  • Yes that's it your entities would be in the vendor in both project – Gregoire Ducharme Mar 28 '18 at 11:45
  • We went with the composer "idea" so i'm marking this as a correct/helpful answer. Thank you. – tsompanis Apr 02 '18 at 20:14
1

Move entities and/or shared parts inside another repository and consider start using git submodules or git subtree. Using this trick you can add a git repository inside another. And you can also update shared content committing and pushing from the submodule.

sensorario
  • 20,262
  • 30
  • 97
  • 159