Lets take the following folder structure:
www/
www/composer.json
www/index.php
www/vendor
www/backend/
www/backend/composer.json
www/backend/index.php
www/backend/vendor
As you can see I have 2 projects, 1 project being a subfolder in the main folder. The main folder gets deployed with heroku and heroku installs the packages from composer.json automatically. Is there a way to instruct heroku or composer.json to also install the www/backend/composer.json packages inside the www/backend/vendor folder?
Or can I specify some of the packages inside the www/compposer.json (not all) to install under the www/backend/vendor folder? Also to generate 2 autoloads file in both www/vendor/ and www/backend/vendor/ ?
Afterall, i was able to do this adding the following in the main composer.json:
"scripts" : { "post-install-cmd" : "cd api;composer install;composer update" }
For people looking for this in the future: As indicated by the answer from keepwalking you can use the "scripts" key in the "composer.json", as described in the "Scripts" section of the Composer documentation. Interestingly, you can also use arrays for individual events.
You can use bash commands, such as cd
and mv
but you can also use &&
to chain commands.
So, my example would be:
{
...
"scripts": {
"post-install-cmd": [
"cd www && composer install",
"cd www/backend && composer install"
]
}
...
}
This has the following flow:
composer install
in the project rootIf 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