Gravitywell - Deploying PHP Apps to Heroku

Deploying PHP Apps to Heroku

Posted by Stuart Forster on 20th December 2011

As an example, we'll deploy a quick phpinfo.php file to Heroku.

Prerequisites: Heroku Gem | Account Setup

1. Create an empty project and Git Repository

mkdir heroku-php
cd heroku-php
git init 

2. Create our test file and commit to Git

vim index.php

Place the following text inside here:

<?php phpinfo(); ?>

Now add to git:

git add index.php

Now commit:

git commit -m "Initial commit"

3. Create your Heroku app

This is the important step. When creating a PHP app on heroku you have to make sure you choose the 'Cedar' Stack.

heroku create --stack cedar

The response should look something like:

Creating freezing-winter-5984... done, stack is cedar |
Git remote heroku added 

Now push to the repository:

git push heroku master 

The response should now look a little like:

Counting objects: 3, done.
Writing objects: 100% (3/3), 244 bytes
Total 3 (delta 0), reused 0 (delta 0)

-----> Heroku receiving push
-----> PHP app detected
-----> Bundling Apache v2.2.19
-----> Bundling PHP v5.3.6
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for PHP   -> web
-----> Compiled slug size is 21.5MB
-----> Launching... done, v4 deployed to Heroku

 * [new branch]      master -> master

Test! You're done

Notice Heroku gives you an auto generated app name. If you look in the first response in step 3, Heroku tells you the URL of your app. Mine is