This sample application for Heroku shows how heroku/heroku-buildpack-multi can be used to combine the Node.js and PHP buildpacks, which allows using Node from inside the PHP buildpack's bin/compile
.
In this example, we're using Bower in a Composer post-install-cmd to install Bootstrap.
To try it out, clone this repo, run heroku create --buildpack https://github.com/heroku/heroku-buildpack-multi
, then git push heroku master
. If you want to port this to an existing app, you'll need to heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-multi
.
You can also quickly deploy a version of this example to Heroku by clicking the button below:
Example: http://heroku-multipack-nodejs-php-ex.herokuapp.com/
- The file
.buildpacks
instructs the Multi Buildpack which buildpacks to run in sequence - The Node.js buildpack installs Bower using NPM (see
package.json
/npm-shrinkwrap.json
) - The Node.js buildpack makes its binaries available to the next buildpack in the chain
- The PHP buildpack runs and installs dependencies using Composer
- As part of the composer install step, the
post-install-cmd
scripts run - That executes
$(npm bin -q)/bower install
-bower install
would work too, asnode_modules/.bin
is on$PATH
on Heroku, but it would likely not work on local development environments, hence the more portable use of prefixing the result fromnpm bin -q
to retrieve said directory name. - Bower installs Bootstrap
- Done!