mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Reduce php calls on Linux and macOS
This commit is contained in:
parent
282305f4d7
commit
9a70be75c2
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user