And I don’t mean change the vendor folder name, that’s easy. I mean getting one package in a custom location, whereas the rest still go into vendor.
This will only work with packages that require composer/installers, so if it isn’t your own package and they don’t require that in, then you can stop reading.
Still here? Awesome. In your vendor package, you need to add the installer
composer require composer/installers
Now in your composer.json, change (or add) the type. The package we just required in is actually to help various CMS’es and frameworks, so you must supply a valid type. Thankfully, it doesn’t matter which we choose, as we override the install path anyway.
Commit that, and then go to your main project. In the composer.json, add the following:
Now when you run composer install, you’ll see everything but your package in the vendor folder, and your custom package in its custom location! 😀
This is real easy, but i keep forgetting which option to use!
If you have separated some of your code into a composer vendor package, and are currently using it in a project, it can be annoying if you need to update it. First you need to open that project up, make your changes, commit, push, wait for tests to pass on travis etc, tag a new version (depending), update packagist if it hasn’t automatically already, and then you can go back into composer and update.
So to save that hassle, composer has the –prefer-source option (–prefer-dist is the one that confused me). This puts the .git folder in your vendor package folder, allowing you to edit, commit, and push from there. Much better.
If you already have the package installed, just delete it. If you haven’t installed it yet, just require it. Both with the –prefer-source option.
composer require delboy1978uk/user --prefer-source
composer update delboy1978uk/user --prefer-source
Replacing my own package above with the one you need, of course. Have fun!