Heroku and mysqli

Giving Heroku another try, it was straight forward to deploy a php app / mysql database. The routine is similar to the OpenShift PaaS and Heroku is not much different using the CLI as well. Console functionality is barebones.

My test app bombed during its maiden run however with a fatal error: Class ‘mysqli’ not found in /app/www/db.php on line 5. I learn that the mysql_connect() syntax in php is old hat and myslqi is to be encouraged instead. The old way works fine on Heroku but for some reason mysqli syntax has not been configured — and my app is peppered with mysqli.

Thanks to this search result, what one does  is to configure Heroku to use a custom buildpack (see below).

1
heroku config:set BUILDPACK_URL=https://github.com/travstoll/heroku-buildpack-php

Then create an empty commit and push the app again to force heroku to recompile the runtime:

1
2
3
git commit --allow-empty -m "empty commit"
git push heroku master

That worked and my app is restored without recoding.

Leave a Reply

Your email address will not be published. Required fields are marked *