I'm deploying a PHP app to Heroku using Composer. Currently I'm using Gulp to compress CSS/JS and commit it to the Git repository. I was wondering if it makes more sense to run the Gulp tasks using Composer's post-install-cmd
. What is the best practice for that?
You use the so-called "multi-buildpack" to perform both a Node.js (to install Gulp) and PHP build upon deploy.
Here's an example I built a while ago that uses Bower to install Bootstrap in a Composer post-install-cmd
, but the principle is going to be the same:
http://heroku-multipack-nodejs-php-ex.herokuapp.com
Sources with README
that explains the process: https://github.com/dzuelke/heroku-multipack-nodejs-php-example
You can also use the composer compile
step if you prefer the Gulp install not to run on each composer install
: https://devcenter.heroku.com/articles/php-support#custom-compile-step
Think of Gulp as an all-purpose task-runner, rather than using Composer's post-install-cmd
(or similar) to bolt on additional tasks. A PHP package manager shouldn't be responsible for fetching or compressing front-end assets, that's not its job. Gulp isn't just for front-end-related tasks.
To me, using gulp-composer makes the most sense.
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