Heroku hates mySQL

So after our meeting we’ve decided to host our project on Heroku to exploit their database hosting.

Heroku encourages the use of Postgres rather than mySQL by Oracle. To make things work:

  1. make a heroku account
  2. make sure you have PHP5+
  3. download composer by running this code in Terminal
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Then to make easier (i.e. access anywhere, anytime without typing in the location of composer.phar into terminal)

 mv composer.phar /usr/local/bin/composer

At this point I feel like we are starting to make things way more complicated than things ought to be. My CPSC310 project was a Node.js web application and for a previous work term I was working with Ruby on Rails.

From what I can tell, it seems like composer is to PHP as npm is to Node.js

 

Next: Go through the tutorial provided; I didn’t.

screen-shot-2017-02-16-at-2-34-50-pm

Heroku is actually really easy to use, from my memory. It works like github where you are just pushing your code to your Heroku repo and Heroku will update accordingly. *magic*

I already had to installed from previous projects but you need to download and install the Heroku command line toolkit.

If you go through the tutorial, it will ask you to git clone a repo that is prepared for the purposes of the tutorial but if you have your own, it’s probably just faster to use your own repo.

Deploying your own project

Once you have Heroku CLI and you have logged in

 heroku login 

, change directories to your project.

In the Terminal:

 heroku create 

This will generate a random slug like pinetree-stack-201923.herokuapp.com

If that’s ok with you continue. If not: this is a great post by Agile Warrior.

So now you can push to both your git and the heroku git. By updating the Heroku git you are updating your web application as well.

Troubleshooting

When I tried to push I got a “Permission denied” …blah…blah…blah… Of course I pushed twice to make sure it wasn’t a “I’m being stupid”error.

Simple fix to this though:

 heroku keys:add ~/.ssh/id_rsa.pub 

adding-ssh-key-to-heroku

After that just

 git push heroku 

and you are good to go.

 

Maybe you also want to read:

Forgetting my SSH passphrase

 

Advertisements

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