Setting up CircleCI Continuous Integration with Laravel – Then deploy Forge or Fortrabbit

Including Continuous Integration is great, but there are many providers to choose from. CircleCI has a pretty decent free plan, but using it for your Laravel app might be a bit confusing.

Instructions for deploying Laravel 5.5 with Circle CI:

This site has a nice boilerplate script:

But if you found a better script, let us know in the comments.

Make sure you have specified the testing environment variables in your .env.testing and phpunit.xml if you are using PHPUnit.

Deploying on Laravel Forge via CI

After that call this script in your final step in config.yml:

  - run:
     name: Run deploy script
     command: sudo chmod +x ./; sudo ./

Then create a script in your app and include the Laravel Forge / Envoyer deployment trigger URL (can be found in your app’s dashboard in Laravel Forge / Envoyer):

# Trigger deployment
# Replace the url below with your envoyer/forge url
curl -s '';

# APPLICATION2 - if you have multiple applications that needs to be deployed and triggered
curl -s '';

echo 'Deployment triggered!'

After this, you can push to Github or Bitbucket and see if the build succeeds and deploys to Laravel Forge / Envoyer. Make sure you disable auto-deploy, as you only would like to deploy to Laravel Forge / Envoyer after a successful CI build.

Deploy on Fortrabbit with CircleCI

Rather want to deploy on Fortrabbit instead of Laravel Forge after a successful CircleCI build?

Read more about using CI with Fortrabbit here.

To setup the deployment to Fortrabbit from CircleCI follow this procedure:

  1. Run this script on a terminal client: ssh-keygen -m PEM -t rsa -C “”
  2. Copy the private key to CircleCI
  3. Go to the project -> SSH Keys Enter hostname: (replace XYX with your Fortrabbit server location)
  4. Add the public key in the Fortrabbit Dashboard’s public SSH key manager
  5. Add the fingerprint that you see in the CircleCI dashboard to the config.yml file:
version: 2
      - add_ssh_keys:
            - "SO:ME:FIN:G:ER:PR:IN:T"

Try to push the updated files to Github or Bitbucket.

See whether this build succeeds. If not, fix the issues until it works.

Add this code to the circleci/config.yml script after the testing steps:

      - run:
         name: Add FRBIT remote
         command: git remote add frbit YOURFRBITGITURL

      - run:
         name: Add FRBIT remote fingerprint to known hosts
         command: ssh-keyscan >> ~/.ssh/known_hosts

      - run:
         name: Deploy to FRBIT
         command: git push frbit

Don’t forget to replace the variables YOURFRBITGITURL and XYZ.

Using these scripts and instructions is on your own risk of course.

Got any suggestions for a better workflow? Let us know!

Travis CI – Laravel Forge / webhook integration

While developing tests for my app, I wanted to have an integration with Laravel Forge in this order:

  1. Push to Github after commit
  2. Tests done by Travis CI
  3. Call the deployment trigger url of Laravel Forge / Envoyer if the test runs successfully. This URL looks like:

To do this, create a travis.yml file like:

language: php

  - 7.1

  - cp .env.travis .env
  - mysql -e 'create database db_testing';
  - composer self-update
  - composer install --no-interaction
  - php artisan migrate

  - vendor/bin/phpunit

  - chmod +x ./; ./

Don’t forget to change the environment in phpunit.xml for example to change to a custom database:

The after_success script

Create a file and insert:


# Trigger deployment
# Replace the url below with your Forge/Laravel url
curl -s '';
echo 'Deployment triggered!'


Using other services than Travis or creating a custom test service

Also thanks to: