Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force Composer to download a local package?

Let's say we have the following directory structure, we assume my-package also exists on Packagist:

- apps
\_ my-app
  \_ composer.json
- packages
\_ my-package
  \_ composer.json

To add my/package as a dependency of my-app, the documentation states we can use the following configuration:

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

However when I composer update, the dependency is still downloaded from Packagist. So, to see, I disabled Packagist.org:

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

I cleared the cache with composer clearcache, removed my/package with composer remove my/package and installed it again with composer require my/package --prefer-source (I didn't understand if --prefer-source is for vcs only). The downloaded package is still not the local one. How to force composer to use the local one?

like image 793
Kwadz Avatar asked Jan 21 '17 17:01

Kwadz


1 Answers

"require": {
    "my/package": "*"
}

In case of VCS or path repository types, you need to specify version of the package you request. So instead of using *, as you have currently, use @dev:

"require": {
    "my/package": "@dev"
}
like image 60
Marcin Orlowski Avatar answered Oct 22 '22 07:10

Marcin Orlowski