How to add gitlab-ci.yml?

Create .gitlab-ci.yml file in the root folder with this code, and commit to your Bitbucket repository. Please note that the parameters given here are only for reference. You can (in fact you should) change them according to your environment.

# Select image from https://hub.docker.com/r/_/php/
image: php:7.2

services:
  - name: mysql:8.0
    alias: mysql

variables:
  MYSQL_ROOT_PASSWORD: "passwd"
  MYSQL_HOST: "mysql"
  PHP_VERSION: '7.2'

before_script:
  # Install git, required for composer
  - apt-get update -yqq
  - apt-get install git zlib1g-dev -yqq
  - curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar
  - chmod +x /usr/local/bin/phpunit

  # Install dev environment
  - docker-php-ext-install zip
  - docker-php-ext-install pdo_mysql
  - docker-php-ext-install mysqli && docker-php-ext-enable mysqli

  # Install composer
  - curl -sS https://getcomposer.org/installer | php

  # Install all project dependencies
  - php composer.phar config cache-files-dir .composercache
  - php composer.phar self-update
  - php composer.phar install --no-progress

test:app:
  script:
    - phpunit --configuration phpunit.xml
    - vendor/bin/phpcs
  # - vendor/bin/phpmd Api,App,Cli,Framework text cleancode,codesize,controversial,design,naming,unusedcode

 

How to add bitbucket-pipelines.yml?

Create bitbucket-pipelines.yml file in the root folder with this code, and commit to your Bitbucket repository. Please note that the parameters given here are only for reference. You can (in fact you should) change them according to your environment.

image: php:7.2.0

pipelines:
  default:
    - step:
        caches:
          - composer
        script:
          - apt-get update -qq && apt-get install -yqq unzip git
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install --prefer-dist --no-scripts
          - mkdir ./test-reports
          - vendor/bin/phpcs --report=junit --report-file=./test-reports/phpcs.xml
          - vendor/bin/phpunit