Spoke too soon: ClearDB, Heroku

We are now live on https://gtheatre304.herokuapp.com !

I updated the Procfile, fiddled with the composer.json and figured out which branch to push to (thanks to my personal on-call IT) and voilà: deployment.

Also turns out that Heroku has a few add-ons available on their site for hosting a database.

I’ve chosen to play around with ClearDB which is a “high speed database for your MySQL powered databases” — that’s us! I’m excited and hopeful that maybe Heroku doesn’t hate MySQL.


Obviously there are bigger stores of memory available for purchase, but with the free version you get 5 MB of storage and 10 connections. We won’t need 10 connections since we are only connecting one web application to the database and hopefully, 5 MB should be enough.

The most recent commit : be70fbd connects a remote MySQL database to our project, courtesy of Heroku. After a few glitches and setbacks — if you look at the commit messages, you’ll know — I have ClearDB connected.

Some of the errors I have experienced with the Heroku how-to provided were actually parsing errors.

So initially, you would want to provision your database to Heroku (there is a tutorial available on the site) and then go into your account page on Heroku and copy and paste the Config Vars for your database.

This is essentially  url to your remote database.


Afterwards, just go into your program and parse the in formation. In the tutorial provided however, Heroku suggests to use

 $CLEAR_DATABASE_URL = "some_stuff";

$url = parse_url(getenv($CLEAR_DATABASE_URL));


This was giving me errors like you would not believe. Upon investigation of parse_url and getenv in the PHP documentation, I figured: “why not just parse the url as a string?” rather than trying to the environment of the string. I’m not sure but I think I just misread the tutorial on Heroku — because the developers there are far better at their job than I am at mine. I think, in hindsight, the code they provided will work if you don’t instantiate the URL as a string variable and pass it through the getenv function because by creating the variable $CLEAR_DATABASE_URL, I think I was effectively transforming what should be a URL to plain string.


TL;DR: this code worked.

The only warning I have for my teammates is that when they are testing their code, they still have to use a local instance of a database. Because of the following error:screen-shot-2017-02-17-at-4-52-24-pm

The MySQL database is linked the the Heroku app which means it will not recognize the non-networking IP address that is localhost.

My proposed solution:

  1. everyone pushes to the Heroku git to test their code
  2. upon populating the remote database, maintain a local copy and continue to use XAMPP as a server environment for testing

I would recommend the second because No.1 can get and will get very messy considering, hypothetically, two people can be pushing to heroku master simultaneously and I’m not sure if Heroku supports ports for its web applications to launch multiple git branches at the same time. Actually, as I am writing this, the more unlikely it sounds. So guys, option numéro 2 por favor.


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s