简体   繁体   中英

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:

在此处输入图片说明

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

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

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"
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM