0

I am learning how to deploy my app on Heroku and need some guidance.

Background:

My app currently runs locally, and accesses MySQL database on my machine to pull data for making phone calls to people via Twilio. The scripts in my app are in PHP. So I what I want to do is to push both the scripts and mysql database onto heroku's cloud and schedule a specific script to run.

I have tried reading tutorials online (the most helpful one has been this), but I am still unable to figure the following:

1) how to push my scripts to heroku using git?

2) how to migrate the mysql db from my local machine to heroku?

3) how to get my scripts connecting to the mysql db in the cloud?

4) how to set up a job to call a specific script in heroku?

Most importantly, I need to figure out steps 1 and 2. How can I push my PHP scripts onto heroku soonest?

stretchr
  • 615
  • 2
  • 9
  • 24
  • You're almost there, read [this](https://devcenter.heroku.com/articles/getting-started-with-php#deploy-the-app) – Raptor Sep 02 '14 at 09:13
  • Yes, this might sound not too smart, but how do I replace the app in the example with my own scripts? – stretchr Sep 02 '14 at 10:02

1 Answers1

1

git init for initating the project to git environment. Now you can able to track or commit files. For pushing to heroku you need to confiqure git

git init

git add .

git commit -m "added commit"

heroku create 

The heroku create command will do two things in front, It will create the new application on heroku domain and add application remote in local,

you can check the heroku remote using git remote -v

Then

git push heroku master

finally heroku strongly recommend you to use postgres. For mysql you may need to take DUMP file.

mysql -u root -p <database name> > file.sql

and after push you can import dump file from heroku bash environment .

Raja Simon
  • 10,126
  • 5
  • 43
  • 74
  • Thanks, need to clarify, where in these commands am I pushing my own scripts/db dump from my local machine? – stretchr Sep 02 '14 at 10:43
  • oh . i guess you need cmd for taking dumb and pushing and importing ah ? – Raja Simon Sep 02 '14 at 10:55
  • 1
    there are few things that OP needs to be considered: 1. `mysql` is not free in `heroku` (use `postgres` instead); 2. OP should learn to dump database from MySQL via `mysqldump`, MySQL Workbench or phpMyAdmin; 3. OP should learn the mechanism & commands of Git, or the source codes will be easily corrupted. – Raptor Sep 02 '14 at 10:59
  • thanks Raptor. I am aware of the payment requirements and git commands, but I need to know how to deploy my scripts- here is where my understanding needs some help..please can you reply the comment above? – stretchr Sep 02 '14 at 13:29
  • @stretchr follow the ans will deploy your script to cloud. What else do you need ? – Raja Simon Sep 02 '14 at 13:33
  • the answer will deploy the app in the example (of the ans) to the cloud, I am unsure of what to change to deploy my own script to the cloud.. – stretchr Sep 02 '14 at 13:35
  • heroku create, followed by git push heroku master...i don't understand how my script sitting in some folder gets pushed to the cloud, or does it? – stretchr Sep 02 '14 at 13:37
  • @stretchr see my ans.. then what else your doubt ? – Raja Simon Sep 02 '14 at 13:46
  • Thanks, how do I know which app those commands are pushing to the cloud? What if I have app1, app2 and only want to push app1 to the cloud? – stretchr Sep 02 '14 at 13:50
  • multiple apps ? but you will only deploy working code to production right ?. – Raja Simon Sep 02 '14 at 13:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/60460/discussion-between-rajasimon-and-stretchr). – Raja Simon Sep 02 '14 at 14:01
  • stretchr ..said in chat and here... Let's say app1 is my code to be pushed to production, how do I specifically choose it using git commands? – stretchr Sep 02 '14 at 14:08