Fix enabling zend extensions

This commit is contained in:
Shivam Mathur 2019-12-19 11:29:27 +05:30
parent 2d488f53fd
commit f2972dcf18
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 44 additions and 12 deletions

View File

@ -59,7 +59,7 @@ jobs:
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, opcache, xdebug, pcov #optional
extensions: xml, opcache, xdebug, pcov #optional
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
coverage: pcov

View File

@ -57,7 +57,7 @@ jobs:
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xdebug, pcov #optional
extensions: xml, opcache, xdebug, pcov #optional
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
- name: Testing PHP version
@ -72,7 +72,7 @@ jobs:
- name: Testing Extensions
run: |
php -m
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
php -r "if(! extension_loaded('xml')) {throw new Exception('xml not found');}"
php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
- name: Testing ini values

View File

@ -17,8 +17,22 @@ add_log() {
fi
}
get_extension_regex() {
extension=$1
case $extension in
"opcache")
echo "^Zend\sOPcache$"
;;
"xdebug")
echo "^Xdebug$"
;;
*)
echo ^"$extension"$
;;
esac
}
step_log "Setup PHP and Composer"
version=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap shivammathur/homebrew-php >/dev/null 2>&1
brew install shivammathur/php/php@"$1" composer >/dev/null 2>&1
@ -37,11 +51,12 @@ add_extension() {
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log $tick "$extension" "Enabled"
elif php -m | grep -i -q ^"$extension"$; then
extension_regex="$(get_extension_regex "$extension")"
if ! php -m | grep -i -q "$extension_regex" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q "$extension_regex"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q ^"$extension"$; then
elif ! php -m | grep -i -q "$extension_regex"; then
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
if [ "$exists" = "200" ]; then
(
@ -49,7 +64,7 @@ add_extension() {
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
else
if ! php -m | grep -i -q ^"$extension"$; then
if ! php -m | grep -i -q "$extension_regex"; then
add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL"
fi
fi

View File

@ -16,6 +16,22 @@ add_log() {
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
get_extension_regex() {
extension=$1
case $extension in
"opcache")
echo "^Zend\sOPcache$"
;;
"xdebug")
echo "^Xdebug$"
;;
*)
echo ^"$extension"$
;;
esac
}
existing_version=$(php-config --version | cut -c 1-3)
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
step_log "Setup PHP and Composer"
@ -96,11 +112,12 @@ add_extension()
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then
extension_regex="$(get_extension_regex "$extension")"
if ! php -m | grep -i -q "$extension_regex" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q ^"$extension"$; then
elif php -m | grep -i -q "$extension_regex"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q ^"$extension"$; then
elif ! php -m | grep -i -q "$extension_regex"; then
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"