diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index 0c764058..143ac5fd 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -209,14 +209,16 @@ setup_php() { status="Found" fix_dependencies >/dev/null 2>&1 fi - ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") - sudo chmod 777 "$ini_file" "${tool_path_dir:?}" - configure_php - ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") - scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") + php_config="$(command -v php-config)" + ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)" + ini_dir="$(php --ini | grep '(php.ini)' | sed -e "s|.*: s*||")" + scan_dir="$ini_dir"/conf.d + ini_file="$ini_dir"/php.ini sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer" + sudo chmod 777 "$ini_file" "${tool_path_dir:?}" semver=$(php_semver) extra_version=$(php_extra_version) + configure_php if [ "${semver%.*}" != "$version" ]; then add_log "${cross:?}" "PHP" "Could not setup PHP $version" exit 1 diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index cde011b1..790ba506 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -203,12 +203,13 @@ setup_php() { add_log "${cross:?}" "PHP" "Could not setup PHP $version" exit 1 fi + php_config="$(command -v php-config)" + ext_dir="/usr/$(grep -Po "extension_dir=..[^/]*/\K[^'\"]*" "$php_config")" + ini_dir=$(php --ini | grep "(php.ini)" | sed -e "s|.*: s*||") + scan_dir="$ini_dir"/conf.d + pecl_file="$scan_dir"/99-pecl.ini semver=$(php_semver) extra_version=$(php_extra_version) - ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||") - scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") - ini_dir=$(php --ini | grep "(php.ini)" | sed -e "s|.*: s*||") - pecl_file="$scan_dir"/99-pecl.ini export ext_dir mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +) link_pecl_file diff --git a/src/scripts/unix.sh b/src/scripts/unix.sh index 206c8ef8..88306a6b 100644 --- a/src/scripts/unix.sh +++ b/src/scripts/unix.sh @@ -119,7 +119,7 @@ configure_php() { # Function to get PHP version in semver format. php_semver() { - grep -Eo 'version="[0-9]+(\.[0-9]+){2}((-?[a-zA-Z]+([0-9]+)?)?){2}' "$(command -v php-config)" | cut -d '"' -f 2 + grep -Eo 'version="[0-9]+(\.[0-9]+){2}((-?[a-zA-Z]+([0-9]+)?)?){2}' "${php_config:?}" | cut -d '"' -f 2 } # Function to get the tag for a php version.