Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Gulp tasks during composer install

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?

like image 855
Till Avatar asked Feb 27 '15 10:02

Till


2 Answers

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

like image 178
dzuelke Avatar answered Sep 19 '22 02:09

dzuelke


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.

like image 45
iainn Avatar answered Sep 18 '22 02:09

iainn