Based on the ideology of pnpm to reduce and reuse shared packages.
composer global require bkief29/pcomposer
Modify your ~/.composer/config.json to include the following:
Replace
%MY_USER%
with your user, or specify a custom path forvendor-dir
{
"config": {
"allow-plugins": {
"bkief29/pcomposer": true
},
"extra" : {
"shared-package": {
"vendor-dir": "/Users/%MY_USER%/.composer/pcomposer",
"symlink-dir": "vendor",
"symlink-enabled": true,
"package-list": [
"*"
]
}
}
}
}
In your project's composer.json:
"config": {
"extra" : {
"pcomposer": {
"exclude": [
"spatie/data-transfer-object"
]
}
}
},
Usage:
pcomposer ~/projects
function pcomposer() {
find $1 -type d \( -name "vendor" \) -maxdepth 2 -print0 | while read -d $'\0' file
do
echo "$file"
cd "$file/../" && composer install
done
}