/heroku-multipack-nodejs-php-example

A sample application for Heroku, showing how heroku/heroku-buildpack-multi can be used to combine Node.js and PHP, using Bower in a Composer post-install-cmd to install bootstrap.

Primary LanguagePHPMIT LicenseMIT

heroku-multipack-nodejs-php-example

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:

Deploy

Example: http://heroku-multipack-nodejs-php-ex.herokuapp.com/

How it works

  1. The file .buildpacks instructs the Multi Buildpack which buildpacks to run in sequence
  2. The Node.js buildpack installs Bower using NPM (see package.json/npm-shrinkwrap.json)
  3. The Node.js buildpack makes its binaries available to the next buildpack in the chain
  4. The PHP buildpack runs and installs dependencies using Composer
  5. As part of the composer install step, the post-install-cmd scripts run
  6. That executes $(npm bin -q)/bower install - bower install would work too, as node_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 from npm bin -q to retrieve said directory name.
  7. Bower installs Bootstrap
  8. Done!