diff --git a/.github/workflows/experimental-workflow.yml b/.github/workflows/experimental-workflow.yml index 4a506260..a2993568 100644 --- a/.github/workflows/experimental-workflow.yml +++ b/.github/workflows/experimental-workflow.yml @@ -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 diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2ee9edbf..e7b62138 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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 diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index c918c8cb..f5f6934f 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -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 diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 499a2958..0e89a247 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -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"