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?
"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"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With