Last active
September 8, 2020 10:42
-
-
Save prisis/4e81f5e52ad7e11518e4d2eb81d7e89d to your computer and use it in GitHub Desktop.
tpecl is a helper to compile and cache php extensions on travis
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 | |
# How to use: | |
# | |
# Copy this to your travis file | |
# | |
# cache: | |
# directories: | |
# - ${HOME}/php-ext | |
# | |
# And add it to your bash file | |
# source ./tpecl.sh | |
# | |
# tpecl mongodb-${DRIVER_VERSION} mongodb.so | |
tpecl () { | |
local EXT_NAME=$1 | |
local EXT_SO_NAME=$2 | |
local EXT_DIR=$(php -r "echo ini_get('extension_dir');") | |
local EXT_CACHE=~/php-ext/$(basename $EXT_DIR)/$EXT_NAME | |
local INI_PATH=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | |
if [[ -f "$EXT_CACHE/$EXT_SO_NAME" ]]; then | |
echo extension=$EXT_CACHE/$EXT_SO_NAME >> $INI_PATH | |
else | |
mkdir -p $EXT_CACHE | |
echo yes | pecl install -f $EXT_NAME && | |
cp $EXT_DIR/$EXT_SO_NAME $EXT_CACHE | |
fi | |
if [[ ! $(php -m | grep -w "${EXT_SO_NAME%.*}") ]]; then | |
echo extension=$EXT_SO_NAME >> $INI_PATH | |
fi | |
} | |
export -f tpecl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Download it with:
wget https://cdn.rawgit.com/prisis/4e81f5e52ad7e11518e4d2eb81d7e89d/raw/765b9ee3a2f2c48edac7f4ecae9f6e02662902a4/tpecl.sh