• PHP
  • 2 MINUTES READ

Using CircleCI with your PHP Application

  • POSTED ON
  • June 10, 2016
  • POSTED BY
  • Aayan Arif
  • POSTED ON June 10, 2016
  • POSTED BY Aayan Arif

CircleCI is a tool which provides us with the functionality to merge, test and deploy code automatically on the server. This helps in minimizing testing and deployment time with no errors. CircleCI is integrated with GitHub using webhook and performs all the functionality on its end. When you push ‘commit to GitHub’, CircleCI starts an action to pull down....

CircleCI is a tool that provides us with the functionality to merge, test and deploy code automatically on the server. This helps in minimizing testing and deployment time with no errors.

CircleCI is integrated with GitHub using webhook and performs all the functionality on its end. When you push a commit to GitHub, CircleCI starts an action to pull down all your latest code from any branch that you have specified, prepares a build with the latest code, and performs tests on it.

These tests will be executed automatically and if all of the code passes, only then will our build be pushed onto the server.

After successful testing, Circle CI provides the optional step of deploying your code on the server. You can set up CircleCI to deploy your code as well. If there is any issue during execution test cases, CircleCI will notify you. You can integrate CircleCI with any modern platform like Slack, using webhook for its notifications.

CircleCI works independently with all tools and Package managers, that help PHP developers test and deploy their code. CircleCI also lets you execute commands, prepare to build and perform tests automatically. Additionally, it provides custom configuration options via circle.yml which is in the root directory.

Steps for CircleCI Execution

1: Source
Circle CI fetches the latest code using GitHub webhooks after you commit or pull requests for a specific branch.

2: Resolve dependencies
CircleCI uses circle.yml to resolve all the dependencies. You can add commands and dependencies in this file. After the first execution, CircleCI saves the dependencies in the cache so that you don’t have to install everything repeatedly.

3: Build
After resolving the dependencies, CircleCI creates a build based on the latest code and all dependencies to create a test environment for the application. Not every language requires compilation time, but if your application needs any compilation before execution, CircleCI does this for you as well (examples CoffeeScript, Less, etc.)

4: Tests
Once the build is ready and CircleCI has created a proper test environment, it starts the execution of your test case like a PHPUnit test case.

5: Notifications
With support for every major team chat tool and email notification, CircleCI will notify you when your attention is required. Build failure notifications include info about exactly which tests failed, so you can fix things in less time.

Benefits

The following are the benefits of CircleCI:

  • Improves Productivity
  • Reduces Risk
  • Scaled with CircleCI
    .

Speed up your testing and development cycle; CircleCI is flexible to run in your environment and scale with your growth. Have peace of mind by reducing bugs and improving the quality of your PHP application.

Sample Circle.yml

machine: 
  timezone: 
    America/Chicago 
  php: 
    version: 5.5.11 
  environment: 
    ENVIRONMENT: development 
    DB_URL: 127.0.0.1 
    DB_NAME: db_name
    DB_USER: db_user
    DB_DATABASE: db_dbname
    DB_HOST: 127.0.0.1 
    DB_USERNAME: db_dbuser
    MONGO_DB_HOST: mongo_host 
    MONGO_DB_DATABASE: mong_db_name
dependencies: 
  override: 
    - composer install --prefer-source --no-interaction 
  pre: 
    - printf "n" | pecl install mongo 
  post: 
    - php artisan migrate --env=development 
    - php artisan db:seed --env=development 
    - php artisan db:seed --class=UserTableSeeder --env=development 
test: 
  override: 
- phpunit

With the introduction of Circle CI in our many teams, we have found it very useful in helping developers’ productivity.

ABOUT THE AUTHOR

Aayan Arif

Content Strategist at vteams - Aayan has over 8 years of experience of working with multiple industries.

0 Comments

Leave a Reply

More Related Article
We provide tips and advice on delivering excellent customer service, engaging your customers, and building a customer-centric business.