问题
I know that I can use composer update vendor/package
but here's my case.
Composer is very slow when updating, I have around 6 packages installed and one local vcs package being loaded from a local folder. When I run composer update
even for that specific local package, composer connects to Packagist to look for other updates and this process is very slow, I don't know if it's my computer or my internet. Is there a way I can tell composer to just update the package from local folder when I run composer update local/package
without contacting Packagist and running through all the heavy json files it downloads?
Note: I know how to load a local composer package. It's loading perfectly, it's just that I'm looking for a way to tell composer just to load the local package without contacting Packagist.
"repositories": [
{
"type": "vcs",
"url": "../local/package"
}
],
My problem is that it's slow to contact Packagist. Running composer update local/package -vvv
Shows that it still downloads json files from packagist even if it's told to update just local/package
.
回答1:
There are multiple ways of speeding the Composer fetch up:
define a custom repo, which points to a local path and
install
with--prefer-source
"repositories": [ { "type":"vcs", "url":"/path/to/your/local/package/packageA" } ], "require":{ "package/packageA" : "dev-master" }
Follow-up trick: if you exactly know the
type
of the repo, then specify it!In other words: do not use
"type":"vcs"
if you can specify"type":"git"
or"type":"svn"
. Composer will skip running through all the repo adapters to figure the correct one out.you could setup Satis and define only the required packages for your project and their dependencies (
"require-dependencies": "true"
). This acts as a package proxy in front of packagist. You would simply fetch from the local Satis mirror/proxy.
Give this a try, to disable the default Packagist repository:
{
"repositories": [
{
"packagist": false
}
]
}
来源:https://stackoverflow.com/questions/29253843/how-to-update-a-single-composer-package