CI for Laravel

The Build Environment

The build environment is designed to match Laravel Forge's environment as much as possible.

The build container has several versions of PHP and NodeJS available. Here is what the build environment has installed:

PHP

The PHP version available is set by your .chipperci.yml file, in the environment section:

environment:
  php: 8.4  # 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4

The following PHP versions are available for use:

  • 8.4
  • 8.3
  • 8.2
  • 8.1
  • 8.0
  • 7.4
  • 7.3
  • 7.2
  • 7.1

The following modules are installed as reported by php -m:

  • bcmath
  • calendar
  • Core
  • ctype
  • curl
  • date
  • dom
  • exif
  • fileinfo
  • filter
  • ftp
  • gd
  • gettext
  • gmp
  • hash
  • iconv
  • igbinary
  • imagick
  • imap
  • intl
  • json
  • ldap
  • libxml
  • mbstring
  • memcached
  • msgpack
  • mysqli
  • mysqlnd
  • openssl
  • pcntl
  • pcre
  • PDO
  • pdo_mysql
  • pdo_pgsql
  • pdo_sqlite
  • pgsql
  • Phar
  • posix
  • readline
  • redis
  • Reflection
  • session
  • shmop
  • SimpleXML
  • soap
  • sockets
  • sodium
  • SPL
  • sqlite3
  • standard
  • sysvmsg
  • sysvsem
  • sysvshm
  • tokenizer
  • wddx
  • xdebug
  • xml
  • xmlreader
  • xmlwriter
  • xsl
  • Zend OPcache
  • zip
  • zlib

Vendor Commands

The $PATH variable is set to include ./vendor/bin, so you can reference commands such as phpunit without needing to write ./vendor/bin/phpunit.

There is no global phpunit command installed. You are encouraged to use phpunit included via your project's composer.json file.

Composer

You can run composer version 1 and 2 in your pipeline. The default composer command is version 2. The command composer1 is available as well.

# Use composer version 1
composer1 install --no-interaction --prefer-dist --optimize-autoloader

# Use composer version 2 with either of these
composer install --no-interaction --prefer-dist --optimize-autoloader
composer2 install --no-interaction --prefer-dist --optimize-autoloader

Alternatively, you can "update" the default version to another major version:

# "Update" composer to version 1
sudo composer self-update --1

composer --version # 1.x.x

# Update composer to version 2
sudo composer self-update --2

composer --version # 2.x.x

Node

The NodeJS version used in the container is set ahead of time within the project's .chipperci.yml file:

environment:
  node: 20

No global Node packages are installed other than node, npm, and yarn.

The $PATH variable is set to include ./node_modules/.bin, so you can reference NodeJS commands without using a relative path.

You can dynamically set which NodeJS version is used. This is useful if the build environment needs a newer minor point release, or if you need to use an older version of NodeJS.

To change node version, run the following in your build pipeline before running any node/npm commands:

# Example: Downgrade NodeJS to 14.16.0
source ~/.nvm/nvm.sh
nvm install 14.16.0
nvm use 14.16.0

# Tell other pipeline steps to
# use this version also
nvm alias default 14.16.0

Browser Testing

Browser testing is available for Dusk tests via the Chrome driver. More documentation on using Laravel Dusk available here.

Other

The following basic utilities are available (although this is not an exhaustive list):

  • curl
  • wget
  • git
  • zip/unzip
  • tar
  • gzip/gunzip

The aws command line utility is not installed globally. The best way to install it is with the following:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Sudo

The sudo command is available to use, in case you need to install other utilities or change configuration.

For example, certain customers from Down Under have needed to change locale settings to get the correct currency in PHP. If you need to do something like that, you may want to run the following (or similar):

echo "en_AU.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen \
    && sudo locale-gen

echo "LANG=\"en_AU.UTF-8\"" | sudo tee -a /etc/default/locale
echo "LANG=\"en_AU.UTF-8\"" >> /home/chipper/.profile
echo "LC_MONETARY=\"en_AU.UTF-8\"" >> /home/chipper/.profile

source /home/chipper/.profile