@flippi
👾 Dev
💻 Tech enthusiast
🎮 Casual gamer

Slim Framework App PHP with deploy in Heroku

Slim Framework PHP application with automatic deployment on Heroku.

Introduction

The main objective of this repo is to be able to automatically deploy our PHP Slim Framework application on Heroku.

1- Forke project

As a first step, we forked this project from the button located at the top right of the repository page.

2- We upload our code

Once forked, we clone the repo with git clone <repo url> and add our PHP code (SLIM Framework) inside the /app/ folder. Then we commit and push the changes.

git add .
git commit -m "first commit"
git push -u origin main

3- Create and configure the App in Heroku

We go to the Heroku page https://heroku.com/, we log in if we have an account or create one.

When you log in, Heroku shows us your dashboard, here we will click on New and then on Create new app:

Heroku1

In this section we add the name of the app, select the United States region and then click the Create app button

Heroku2

Now we go to the Deploy section and click on the GitHub option, which will show us our user or we will have to log in with GitHub. Then we look for the name of our repo and it will appear below:

Heroku3

We select the repo and click on Connect

Once this is done, we choose the github branch that we want to deploy with our Heroku application, in our case main, and click Enable Automatic Deploys. In this way, every time a modification is made to this branch, Heroku will automatically update the application.

Heroku4

The last thing we should do is click the Deploy Branch button. This is only done once, then it will be done automatically.

Heroku5

We can check from GitHub if the deployment was done successfully.

Heroku6

From the button View deployment we access the URL of the deployed app.

https://slim-php-heroku.herokuapp.com/

Enjoy!

2021