This guide provides a walkthrough of .razorops.yaml for a PHP application based. This article consits of 2 ways of deploying a PHP applications through Razorops.

Docker based

I assume you are familiar with Docker concepts, if not please refer here to know more about the advantages of Docker.

Build/Test steps

If you have Dockerfile in the root of your source repository, you can build a container image and use that container image to run your test suit. For example -

tasks:
    build-image:
        type: build
        name: registry.example.com/php/app
        tags: ["${CI_COMMIT_SHA}", "latest"]

    build-executable:
        image: registry.example.com/php/app:latest
        commands:
            - phpunit TestDirectory/NameTest

Non-Docker based

Downloading dependencies

You can use official ruby docker image and provide commands to download dependencies -



 



tasks:
    build-deps:
        image: php:7.1.8-apache
        commands:
            - composer install

Read more how to use this image on dockerhub docs.

TIP

You can further speedup the workflow by caching bundler dependencies so that every subsequent build then performs just incremental changes on top of that during bnudle install which may lead to even faster builds.

Execute test suite

Using official php docker image:



 








tasks:
    build-deps:
        image: php:7.1.8-apache
        commands:
            - phpunit testDirectoryName
        environment:
            DATABASE_URL: postgres://root@db:5432
        services:
            db:
                image: postgres:9.6

You can additionally provide environment variables and provide service dependencies to run your test suite.