Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AliceWonderMiscreations/a3d8240c73eb1755e8243aa2c5331736 to your computer and use it in GitHub Desktop.
Save AliceWonderMiscreations/a3d8240c73eb1755e8243aa2c5331736 to your computer and use it in GitHub Desktop.
Travis and PHP
Getting both libsodium and apcu working in travis was a pain in the buttucks for me. This is what finally worked:
----------------------------.travis.yml--------------------------------------------------------------------------
language: php
php:
- '7.1'
- '7.2'
env:
- PHPUNIT_VERSION="^7"; PSRSIMPLE_VERSION="^1.0.1"; AWSIMPLE_VERSION="^1.0.0"
before_install:
- sudo add-apt-repository ppa:ondrej/php -y
- sudo apt-get -qq update
- sudo apt-get install -y libsodium-dev
- printf "\n" | pecl install apcu
install:
- composer require phpunit/phpunit:${PHPUNIT_VERSION}
- composer require psr/simple-cache:${PSRSIMPLE_VERSION}
- composer require awonderphp/simplecache:${AWSIMPLE_VERSION}
before_script:
- phpenv config-add travis.php.ini
- pecl install libsodium
script: vendor/bin/phpunit --testdox
-----------------------------------------------------------------------------------------------------------------
The environmental variables, travis will use an old version of phpunit if you don't specify a newer one and tell
composer to install it. The other two may not have been needed, but after travis was using an old version of
phpunit I don't want to take chances.
It seems their ubuntu environment doesn't have libsodium-devel available by default, so I had to add a ppa and then
after installing the library, use pecl to install it.
For apcu - I couldn't install it via pecl in the before_script section because my composer.json requires it and
that caused travis to fail - which is weird, because my composer.json also requires phpunit 7 but it kept using a
crusty version. Well anyway I had to move the pecl install of apcu to the before_install section *and* I had to
echo a newline and pipe it to the pecl install command. Why use pecl to install apcu? because trying to apt-get
install php-apcu simply did not work. I guess I don't have the right ppa for it?
The travis.php.ini is needed to allow phpunit to work with apcu - cli mode has to be enabled. This is what it has:
-----------------------------travis.php.ini--------------------------
apc.enabled=1
apc.enable_cli=1
---------------------------------------------------------------------
Anyway travis will now run the unit tests I need for my SimpleCacheAPCu and SimpleCacheAPCuSodium libraries.
Gah it was a pain in the arse.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment