Heroku needs to be told it’s PHP not Node.js

(Note – this is a quick dot-point summary for my own benefit. It’s not written up properly.)

So I signed up for Heroku, and spent about three hours trying to work out why my app wouldn’t work.

I was getting errors about “no such file” and it was driving me nuts. I eventually worked out that the /vendor/bin/heroku-php-apache2 file seemed to be missing. So I did composer require --dev heroku/heroku-whatver and that didn’t help much.

Then I started reading about Heroku buildpacks. And eventually I worked out that there was no buildpack specified, so it was defaulting to Node.js instead of PHP.

So I did heroku buildpacks:add https://github.com/heroku/heroku-buildpack-php (and then had to do another git push to heroku) and suddenly everything works! Hooray!

Steps to reproduce the problem: (assuming you’ve got Laravel 5.1 and the Heroku toolbelt installed)

laravel new mydemo
cd mydemo
git init
git stage .
git commit -m "first commit"
heroku login
heroku create
git push heroku master
heroku ps:scale web=1
# Scaling dynos... failed / No such process type web defined in Procfile.
echo "web: vendor/bin/heroku-php-apache2 public/" > Procfile
heroku ps:scale web=1
# Scaling dynos... failed / No such process type web defined in Procfile.
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-php
git push heroku master
# Nothing happens, nothing to commit...
echo "Something to commit" > trashme.txt
git stage .
git commit -m "added something"
git push heroku master
# NOW it detects that it's a PHP app
heroku ps:scale web=1
heroku open
# ... and NOW we get a Laravel page. It's "Whoops, looks like something went wrong", but it's something. :-)

Steps to get it to actually work: (assuming you’ve got Laravel 5.1 and the Heroku toolbelt installed)

laravel new mydemo
cd mydemo
git init
git stage .
git commit -m "first commit"
heroku login
heroku create
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-php
git push heroku master
heroku ps:scale web=1
heroku open
# ... and NOW we get a Laravel page. It's "Whoops, looks like something went wrong", but it's something. :-)

Advertisements
Heroku needs to be told it’s PHP not Node.js

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s