Skip to content

A template that helps integrate Docker, CircleCI and Heroku in a PHP project for Continuous Integration and Continuous Deployment.

Notifications You must be signed in to change notification settings

arc30/php-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A template that helps integrate Docker, CircleCI and Heroku in a PHP project for Continuous Integration and Continuous Deployment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published