Skip to content

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.

License

Notifications You must be signed in to change notification settings

dzuelke/heroku-multipack-nodejs-php-example

Repository files navigation

heroku-multipack-nodejs-php-example

This sample application for Heroku shows how Heroku's support for multiple buildpacks can be used to run both the Node.js and PHP buildpacks during a deploy, 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, then heroku buildpacks:add heroku/nodejs followed by heroku buildpacks:add heroku/php, and finally deploy using git push heroku master. If you want to port this to an existing app, you'll need to use a combination of heroku buildpacks:set and heroku buildpacks:add to set the correct buildpack order.

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 heroku buildpacks:add command is used to set multiple buildpacks on an app (see heroku buildpacks)
  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!

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages