Miguel Stevens
Miguel Stevens

Reputation: 9201

Composer local repository not installing (for Laravel)

I'm working on a Laravel package, I'm trying to add it to my project using the VCS option in my composer.json but it's not installing. I've tried the following

Linking to the absolute path on my Vagrant machine

"repositories": [
    {
        "type": "vcs",
        "url": "/home/vagrant/Code/cld/gallery/packages/Notflip/cld/"
    }
],
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "notflip/cld": "dev-master"
},

Linking to the absolute path of my Windows machine

"repositories": [
    {
        "type": "vcs",
        "url": "D:/Sites/cld/gallery/packages/Notflip/cld"
    }
],
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "notflip/cld": "dev-master"
},

But nothing is working, the project is located as follows:

enter image description here

I'm using Vagrant (Homestead) on a Windows machine.

Upvotes: 1

Views: 5237

Answers (3)

Pau Benet Prat
Pau Benet Prat

Reputation: 1

I do more or less the same as @roj-vroemen but a little bit different.

In my case a create a folder called packages in my projects directory and add my secondary packages on it.

  • projects-dir
    • foo-project
    • hello-world-project
    • packages
      • my-third-party-package

On my-third-party-package composer.json I add the following lines:

{
    "name": "paubenetprat/my-third-party-package",
    "description": "My third party package description.",
    "type": "library",
    "require": {
        ...
    },
    "minimum-stability": "stable"
}

After that, on my main project composer.json (foo-project) I add the following:

"repositories": [
    {
        "type": "path",
        "url": "../packages/my-third-party-package",
        "options": {
            "symlink": true
        }
    }
],
"require": {
    "paubenetprat/my-third-party-package": "dev-master"
}

To end up you just need to run:

composer update paubenetprat/my-third-party-package

It's important to specify dev-[current-project-branch]. If you are working on a feature (feature/whatever-your-are-doing) on your third party package you should specify it on you main project composer:

"require": {
    "paubenetprat/my-third-party-package": "dev-feature/whatever-your-are-doing"
}

Upvotes: 0

Roj Vroemen
Roj Vroemen

Reputation: 1892

Try changing it to this:

"repositories": [
    {
        "type": "path",
        "url": "packages/Notflip/cld"
    }
],
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "notflip/cld": "*"
},

And adding the following to your composer.json

"minimum-stability": "dev"

You'll find more info about this here: https://getcomposer.org/doc/05-repositories.md#path

Upvotes: 6

Travis B
Travis B

Reputation: 5288

Vcs is for version controlled not local. You would probably have more luck using class map and pointing that to the package root.

Upvotes: -1

Related Questions