Getting going on Codeship and Laravel is pretty easy.

Once you setup codeship to work with your github account just pull in your repo and set your Testing scripts as follows. (they have a ui for ENV variables as well)

Codeship Testing Settings [easier copy paste bottom of article]


You can do this in their UI as well. But at this point I am

  • Setting up the composer token for any private repos that application might have
  • Setting up .env for their specific needs as well eg MYSQL_*

For the Database to use their settings I have to edit config/database.php


return [

    'fetch' => PDO::FETCH_CLASS,

    'default' => env('DB_CONNECTION', 'mysql'),

    'connections' => [

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', env('TEST_ENV_NUMBER')),
            'username'  => env('DB_USERNAME', env('MYSQL_USER')),
            'password'  => env('DB_PASSWORD', env('MYSQL_PASSWORD')),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,




env('DB_USERNAME', env('MYSQL_USER')),

So we default to theirs if ours is not there. Finally when we run the test I set the db to the name they want

DB_DATABASE=test phpunit

Envoy Deploy

After it passes I can use Envoy to deploy it.

The Envoy scripts are not on Forge but use to be so a lot of the naming matches.

Under the Codeship Deployment page I set

composer global require "laravel/envoy=~1.0" && /home/rof/.composer/vendor/bin/envoy run deploy_dev

In that script do what ever you need to make this thing deploy for example.

@servers(['dev' => ''])

@task('deploy_dev', ['on' => 'dev'])
    cd /home/forge/app
    git reset --hard HEAD
    git pull origin dev
    composer config -g foo
    rm -rf vendor
    composer install
    composer dump-autoload
    php artisan migrate:refresh --seed
    bower install

We do not do this on Prod. Someone with proper permissions will run Envoy locally once the tests are passing.


Easier copy paste

# Set php version through phpenv. 5.3, 5.4 and 5.5 available
phpenv local 5.5
# Install dependencies through Composer
composer config -g foo
touch .env
echo "APP_ENV='testing'" >> .env
echo "MYSQL_TESTING_URL='localhost'" >> .env
echo "MYSQL_TESTING_URL='localhost'" >> .env
echo "APP_KEY=foo" >> .env
echo "CACHE_DRIVER=file" >> .env
echo "SESSION_DRIVER=file" >> .env
echo "QUEUE_DRIVER=sync" >> .env
echo "MAIL_DRIVER=smtp" >> .env
echo "" >> .env
echo "MAIL_PORT=2525" >> .env
echo "" >> .env
echo "MAIL_PASSWORD=foo" >> .env
echo "MAIL_ENCRYPTION=true" >> .env
echo "STRIPE_API_SECRET='foo'" >> .env
echo "STRIPE_PUBLIC='foo'" >> .env
composer install --dev