slejnej / asset-installer
Install npm from composer script
1.0.3
2025-10-29 13:05 UTC
Requires
- php: >=8.1
- ext-json: *
- symfony/filesystem: *
- symfony/process: *
- symfony/yaml: *
This package is auto-updated.
Last update: 2026-03-01 00:37:14 UTC
README
Install all your npm assets via composer
Installation
- install via composer
composer req slejnej/asset-installer - add asset installation script to your composer
"scripts": { "post-install-cmd": [ "slejnej\\AssetInstaller\\InstallerHandler::installAssets" ] } - add npm packages direct to your composer
"extra": { "npm": { "leaflet": "^1.7.1" } } - run
composer install
In case
If this package is included in one of your vendor dependencies, then the scripts are not run for security reasons. As a work around you can use in primary composer.json something like this:
find ./vendors -maxdepth 2 -type f -name composer.json -exec bash -c "cat {} | grep ::installAssets && composer install --working-dir $(dirname {})" \;
It will find all the files that contain php command installAsset and then execute composer install in containing folder.
Update ./vendors folder where it should look in and adjust maxdepth and update you composer` executable.