Skip to content

Latest commit

 

History

History
73 lines (45 loc) · 3.19 KB

README.md

File metadata and controls

73 lines (45 loc) · 3.19 KB

CI/CD pipeline for PHP project

A basic pipeline that integrates Docker, CircleCI and Heroku in a PHP project for Continuous Integration and Continuous Deployment.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  1. An account on CircleCI created using your GitHub profile.

  2. An account on Heroku.

  3. Docker and Docker Compose installed on your system.
    sudo apt-get install docker.io docker-compose

Installing

Fork and clone this repository.

php-template directory contains:

  1. src is the folder where you will write your PHP source code files.
  2. database is the folder where you save your mysql database dump. Create a database dump of your project using mysqldump and save it here as db.sql.
  3. tests is the folder where your test files using PHPUnit are stored. Tests are explained in a later stage.

Heroku

  1. Create a new project
  2. Go to account settings and copy your API Key
  3. Add ClearDB MySQL by clicking Configure Add-ons on your project's overview page.

CircleCI

  1. Add and set up this forked project and click on Start Building. Here the build will fail, but continue to step 2.
  2. Go to this project's settings and navigate to environment variables section to add the following three environment variables.
NAME:   HEROKU_API_KEY  
VALUE:  the key that you copied from heroku
                 
NAME:  HEROKU_APP_NAME                
VALUE: your project name on heroku

NAME:  HEROKU_USERNAME               
VALUE: email id used to login for heroku
  1. Rebuild the project. The build should now be fixed.

Running the tests

We use PHPUnit 7.0 for unit testing.
This project contains sampleEmail.php in src directory and corresponding EmailTest.php in tests directory.

Place your unit tests (in line with PHPUnit) corresponding to source code files in tests directory.

Deployment

Open your app's Heroku Dashboard to find your PHP project deployed. Visit https://<your-app-name>.herokuapp.com/ to see your website.

Acknowledgements