Skip to content

Instantly share code, notes, and snippets.

@CHH
Last active December 15, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CHH/5188779 to your computer and use it in GitHub Desktop.
Save CHH/5188779 to your computer and use it in GitHub Desktop.
Configuring a Heroku Buildpack via the composer.json?

Unofficial Heroku Buildpack for PHP

This Heroku Buildpack adds more advanced support for PHP.

  • Runs apps written for both PHP 5.4 and 5.3
  • Supports Composer dependencies and caching of the vendor/ directory for fast deploys
  • Simple configuration via the project's composer.json
  • Stable and fast setup using NGINX, PHP-FPM and Zend Optimizer Plus

App Configuration

This build pack gets enabled if the project has a file named composer.json in its project root. The simplest way to get set up is to use a framework preset:

{
    "extra": {
        "heroku": { "framework": "symfony2" }
    }
}

Valid framework presets include:

  • symfony2
  • zf2
  • zf1
  • silex

You can also configure the settings manually if you're not using one of the before listed frameworks. The two main settings of interest are: document-root and index:

  • document-root: Publicly accessible files of your project. Typically named public, web or htdocs — but can also be the project's root (e.g. for Wordpress, or most CMS installs)
  • index: This file receives all requests which don't specify an existing PHP file in the request URI.

Available Versions

TODO

  • How to handle custom extensions?
  • Run pecl install <extension> on every ext- entry in the require section?
  • How to handle traditional PHP apps, which call .php files from the doc root (e.g. Wordpress)?
{
"name": "acme/acme-app",
"require": {
"php": "~5.4.0"
},
"extra": {
"heroku": {
"framework": "symfony2"
}
}
}
{
"require": {
"php": "~5.3.8",
},
"extra": {
"heroku": {
"document-root": "",
"index": "index.php"
}
}
}
{
"require": {
"php": "~5.3"
},
"extra": {
"heroku": {
"document-root": "htdocs",
"index": "htdocs/index.php",
"engines": {
"php": "5.3.23",
"nginx": "~1.2.0"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment