Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get composer "path" repository to work

I have a directory structure like so:

composer.json < Main   packages/     balunker/       testpackage/         composer.json < Package         src/           TestPackage.php 

The main composer.json looks like this:

{     "name": "vagrant/composer-test",     "repositories": [         {              "type": "path",             "url": "packages/*/*"         }     ],     "require": {         "balunker/testpackage": "*"     } } 

While the package composer.json looks like so:

{   "name": "balunker/testpackage",   "autoload": {     "psr-4": {       "Balunker\\": "src/"     }   } } 

On composer update I simple get a message that the package could not be resolved. No symlinks are created and no package is installed. I have literally spent half of my day figuring this out, without any success.

I also uploaded a composer update -vvv verbose output of this: http://pastebin.com/mMRHsACk.

My composer version is the latest (as of 20th of April 2016 at 2:39pm UTC) and all of this is running inside Vagrant (Debian).

ANY recommendation from hereon is greatly appreciated. I really don't know what else to do any more.

like image 902
devboxr Avatar asked Apr 20 '16 13:04

devboxr


People also ask

Why is my composer not working?

Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

How do I add a repository to composer?

You can add more repositories to your project by declaring them in composer. json . Repositories are only available to the root package and the repositories defined in your dependencies will not be loaded.

How do I find the composer path?

Installation - Windows# This is the easiest way to get Composer set up on your machine. Download and run Composer-Setup.exe. It will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line. Note: Close your current terminal.


1 Answers

I posted the issue on Github as well and it turns out that the documentation is a little misleading. It says:

{     "repositories": [         {             "type": "path",             "url": "../../packages/my-package"         }     ],     "require": {         "my/package": "*"     } } 

However, if you just have a local repo without releases, you have to use:

{     "repositories": [         {             "type": "path",             "url": "../../packages/my-package"         }     ],     "require": {         "my/package": "dev-master"     } } 

The version dev-master is the key here (given that you are working on the master branch). This was mildly infuriating, but thanks to some helpful composer contributors, I could finally get a grip on this.

I hope this may help somebody in the future.

Good luck!

like image 182
devboxr Avatar answered Oct 07 '22 20:10

devboxr