Reputation: 2315
Let's say the symfony project a contains a bundle called MyCompany/MyBundle
in the root folder of the project.
As this bundle is some kind of standard software for all my projects, I want to share them easily and copy it to project b, c, ...
What is the best way to sync this (private) Bundle?
*Problems with Git/Composer solution: This would need two repos, one for the project and one for the Bundle, but the Bundle is within the project. Moreover composer would download it to vendor
on the other projects and not the root folder)
Upvotes: 1
Views: 444
Reputation: 48865
There is a second approach which comes in handy when the shared bundle is still under heavy development. Something like:
projects
shared\src\MyBundle
project1
project2
etc
Edit projectx\app\autoload.php and add a path to your shared bundle src so everyone can find the shared code. Something like:
$loader = require __DIR__.'/../vendor/autoload.php';
$loader->add('MyBundle', __DIR__ . '/../../shared/src');
Now changes made to MyBundle will be automatically accessed by the other projects.
Eventually when the shared bundle is stabilized, you can turn it into a package and use composer to install into vendor. But during development, this approach works well for me.
Upvotes: 1
Reputation: 12740
As this bundle is some kind of standard software for all my projects ...
In such case, you should extract it into a stand-alone bundle so that you can include it in composer.json of your projects. You can then see your bundle in vendor/...
folder.
If your bundle doesn't depend on any parameter coming from main projects, you can see how it is done here Creating a simple symfony vendor bundle to use it in a main project.
If your bundle does depend on parameter(s) coming from main projects, you can see how it is done here: Creating an encrypt-decrypt symfony bundle that depends on config parameters of main application
Regarding to your concerns about time it takes to update projects, you shouldn't worry about it because:
It wouldn't take more than 2 minutes to update bundle on given project.
Like @Jason Roman said, you get consistency otherwise highly likely you might do things differently in some projects. Trust me, it happens!
You want to do know the "...best way to sync bundle
".
Upvotes: 1