ChocoDeveloper
ChocoDeveloper

Reputation: 14578

What's the correct way for reusing bundles across different projects with Composer and git in Symfony 2?

I want to reuse a bundle, eg: Company/CommonBundle

So what I need to know is how to turn a bundle created with 'php app/console generate:bundle', into a vendor bundle, installable through Composer, and versioned with git.

There seems to be a convention for vendors names, eg: 'monolog/monolog/src/Monolog'. Is there a guide for that?

Upvotes: 2

Views: 309

Answers (2)

ChocoDeveloper
ChocoDeveloper

Reputation: 14578

All right I figured this out

1) uninstall the newly created bundle and move it somewhere else
2) create a git or hg repository for it, commit and push
3) add the dependency to your project, in composer.json
4) run 'composer update nothing'

That's it. Composer downloaded the repository, so you can modify it as needed, commit/push and make it available to all your other projects by following 3) and 4). If the bundle is already installed, you update it like this: 'composer update mybundle'. Enjoy.

Now all I need to figure out is how to have the bundle auto-added to AppKernel.php, etc. If you find how to do this, please share it.

Upvotes: 1

greg0ire
greg0ire

Reputation: 23255

You can use satis for that. I have never used it myself but I have been told by Stof (himself!) that it is the way to go if you want to have some sort of private composer repository.

Upvotes: 1

Related Questions