Checking PHP Major Version on Travis-CI

c9s
CornelTEK
Published in
1 min readMay 19, 2017

Chances are, you might want to run tests for both PHP5 and PHP7 on Travis-CI. However, you will need to install different extension version to make it compilable for PHP5 or PHP7.

And so here is the simple check using bash substr:

if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]] ; then
... do something for php7
elif [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]] ; then
... do something for php 5
fi

Here is the script that installs the APCu extension for both PHP5 and PHP7.

--

--

c9s
CornelTEK

Yo-an Lin, yet another programmer in 21 century