-
-
Save VijitCoder/c71fe297350448e5e7f5813e2f9b3481 to your computer and use it in GitHub Desktop.
`tpecl` is a helper to compile and PHP extensions in TravisCI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Here is an example of travis config with using of `tpecl` | |
language: php | |
dist: xenial | |
os: linux | |
cache: | |
directories: | |
- $HOME/.composer/cache/files | |
jobs: | |
fast_finish: true | |
include: | |
- php: "7.4" | |
before_install: | |
# Attach PECL helper | |
- source ./tpecl.sh | |
before_script: | |
# Add existing extensions to PHP config. | |
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini | |
# Install PHP extensions via PECL. | |
# Note: such extensions are adding to config automatically after installation and don't required additional | |
# manipulations. | |
- tpecl mcrypt-1.0.2 mcrypt.so | |
- tpecl stomp stomp.so | |
- tpecl igbinary igbinary.so | |
script: | |
- composer install | |
- composer validate --no-check-all --strict | |
# Run PHPStan | |
- php vendor/bin/phpstan analyse . --level=5 --memory-limit=1g --configuration=phpstan.neon | |
# Run the whole unit tests suite. FYI: the last word here is the name of suite. | |
- vendor/bin/codecept run unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Uses in Travis | |
# | |
# Inspired by https://gist.github.com/prisis/4e81f5e52ad7e11518e4d2eb81d7e89d | |
# | |
# How to use | |
# | |
# Add it to your bash file: | |
# source ./tpecl.sh | |
# | |
# Then you can calling like this: | |
# tpecl mongodb-${DRIVER_VERSION} mongodb.so | |
tpecl () { | |
local PECL_EXT_NAME=$1 | |
local EXT_FILE_NAME=$2 | |
local EXT_DIR=$(php -r "echo ini_get('extension_dir');") | |
local INI_PATH=~/.phpenv/versions/$(phpenv version-name)/etc/php.ini | |
if [[ -z $PECL_EXT_NAME || -z $EXT_FILE_NAME ]]; then | |
echo 'Wrong call. Must be passed extension name in PECL and extension file name (.so)' | |
exit 1 | |
fi | |
if [[ -n $(php -m | grep -wi "${PECL_EXT_NAME}.*") ]]; then | |
echo "Extension '$PECL_EXT_NAME' already exists among PHP modules. No need to install." | |
exit 0 | |
fi | |
if [[ -f "$EXT_DIR/$EXT_FILE_NAME" ]]; then | |
echo "Extension '$PECL_EXT_NAME' already installed but not added to PHP config. I'll do it now." | |
echo extension=$EXT_FILE_NAME >> $INI_PATH | |
else | |
sudo apt-get update | |
sudo apt-get install libssl-dev gcc make autoconf libc-dev pkg-config | |
echo yes | pecl install -f $PECL_EXT_NAME || exit 2 | |
fi | |
} | |
export -f tpecl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original gist of
tpecl
supports Travis caching feature. It should reduce the time of dependencies building.I'm not sure that it works as expected. In the Travis manual said:
But we're using
tpecl
inbefore_script
section (see example above) which obviously happens before cache.Need to dig in there more.