mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 13:23:05 +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"
|
status="Found"
|
||||||
fix_dependencies >/dev/null 2>&1
|
fix_dependencies >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
php_config="$(command -v php-config)"
|
||||||
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
|
ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)"
|
||||||
configure_php
|
ini_dir="$(php --ini | grep '(php.ini)' | sed -e "s|.*: s*||")"
|
||||||
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
scan_dir="$ini_dir"/conf.d
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
ini_file="$ini_dir"/php.ini
|
||||||
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
||||||
|
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
|
||||||
semver=$(php_semver)
|
semver=$(php_semver)
|
||||||
extra_version=$(php_extra_version)
|
extra_version=$(php_extra_version)
|
||||||
|
configure_php
|
||||||
if [ "${semver%.*}" != "$version" ]; then
|
if [ "${semver%.*}" != "$version" ]; then
|
||||||
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -203,12 +203,13 @@ setup_php() {
|
|||||||
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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)
|
semver=$(php_semver)
|
||||||
extra_version=$(php_extra_version)
|
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
|
export ext_dir
|
||||||
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
||||||
link_pecl_file
|
link_pecl_file
|
||||||
|
@ -119,7 +119,7 @@ configure_php() {
|
|||||||
|
|
||||||
# Function to get PHP version in semver format.
|
# Function to get PHP version in semver format.
|
||||||
php_semver() {
|
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.
|
# Function to get the tag for a php version.
|
||||||
|
Loading…
Reference in New Issue
Block a user