Reputation: 4862
At our company we aim to use Symfony2 for all our new projects. There are a couple of additional bundles that we almost always add to the projects, such as the FOSUserBundle and KnpMenuBundle. We would like to maintain a composer.json file that we could simply copy to a new project folder, run composer.phar install
(or create-project, whichever would work) and have it install symfony2 with all dependencies and the additional bundles that we want to use.
In other words, the goal is NOT to have to first run php composer.phar create-project symfony/framework-standard-edition path/ 2.2.1
, then edit the composer.json in order to add/remove bundles, and finally run composer.phar update to install the bundles we need.
Any thoughts on how this could be achieved?
Upvotes: 0
Views: 396
Reputation: 52493
You could create a vcs ( i.e. git ) repository for your composer.json always check-in / commit all your changes to.
As composer uses json and there is no native support for comments json it is a bit harder to have a composer.json where you can just comment / uncomment bundles you install on a regular basis.
But there are 2 ways of accomplishing that goal.
1) use IgorW's composer-yaml converter which can convert composer.json to a .yml file an backwards.
2) Seldaek / Jordi Boggiano mentioned another way comments can be implemented in composer.json.
{
"_comment" : {
"friendsofsymfony/rest-bundle" : "0.12.0",
"_" : "_"
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "*@dev",
// ... more stuff here
},
// more stuff here
}
This way you can easily copy bundles in and out of your current installation by just moving the lines from comment to require. ( the "_" : "_" entry is there to have a trailing comma after all bundles in _comment and still have valid JSON ).
... but this all does NOT give you a working project right out of the box.
Conclusion:
Most Bundles need configuration and at least all have to be registered in the Kernel in order to work.
Just having a composer.json in your repository wont help.
You can fork symfony/symfony-standard ... add all your desired changes ( registering bundles, changing composer.json ) in your repo and maintain this repo.
Maintaining this repo will require some work as a forked repo does not update itself with the latest commits. You will have to merge in the latest commits from symfony/symfony-standard if you want to keep your repo up-to-date.
But creating an own is definitely the way to go ... only having a composer.json you can pass around in order to have a working project with all your configuration and bundles after calling "composer install" is (currently) not possible.
Upvotes: 1
Reputation: 12033
You can fork symfony-standard at github, modify composer.json, update composer.lock and then checkout from your own copy and run composer install
Upvotes: 1