Reputation: 689
We'd like to create a bundle which can deployed via composer/packagist for others to use. It'll wrap the logic created by the owners of MessageBird. Basically a kind of Service which will indeed be called with the container via ourvendor.messagebird.messaging
.
Since it's a type of bundle (as per the docs of Sf3), we created a bundle while following the documentation: http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_bundle.html
As the directory /src
we used /vendor
instead. That's when it all went wrong. Our namespace could not be located, loaded or even when we manually added it to the autoloading classes of Composer it failed all the same.
The question is, what is the best practice to go about this? We got it working right now and what we did was the following:
bin/console generate:bundle --shared --namespace=OurVendor/MessageBird/MessageBirdBundle --bundle-name=MessageBirdBundle --format=yml
/src/OurVendor
directory to /vendor/OurVendor
as the only way to get a perfect generation was to use the default /src
folder."OurVendor\\":"vendor/"
to the "autoload/psr-4" directive in root composer.jsoncomposer dumpautoload && bin/console cache:clear -e dev
which resulted in an error.composer -o update
which checked all dependencies and updated accordingly, including autogenerated autoload filesAppKernel.php
class and cleaned the cache again.After all this it worked but the documentation said no such thing about developing a 3rd party vendor bundle. http://symfony.com/doc/current/bundles/best_practices.html
So long story short, did we go about it the wrong way or what?
Upvotes: 2
Views: 966
Reputation: 37048
/vendor
directory is managed by composer. Do not copy/move anything there. Don't even edit anything there, unless you understand all consequences.
When you create a shared bundle, you need to push it to a VCS of your choice, and add it as a dependency in composer.json
of the project which uses it.
When you run composer update
it will check-out your bundle into /vendor
directory and generate correct autoload file.
Please read more how to use private repositories with composer.
Upvotes: 1