mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Refactor add_extension
This commit is contained in:
parent
62d47dd238
commit
9ea5899759
@ -78,22 +78,17 @@ add_brew_extension() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to setup extensions.
|
||||
add_extension() {
|
||||
# Helper function to add an extension.
|
||||
add_extension_helper() {
|
||||
local extension=$1
|
||||
prefix=$2
|
||||
enable_extension "$extension" "$prefix"
|
||||
if check_extension "$extension"; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
|
||||
run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
|
||||
else
|
||||
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
|
||||
run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
|
||||
else
|
||||
pecl_install "$extension" >/dev/null 2>&1 &&
|
||||
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
||||
fi
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
pecl_install "$extension" >/dev/null 2>&1 &&
|
||||
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
||||
fi
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
}
|
||||
|
||||
# Function to handle request to add phpize and php-config.
|
||||
|
@ -109,6 +109,18 @@ configure_pecl() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to add an extension.
|
||||
add_extension() {
|
||||
local extension=$1
|
||||
prefix=$2
|
||||
enable_extension "$extension" "$prefix"
|
||||
if check_extension "$extension"; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
else
|
||||
add_extension_helper "$extension" "$prefix"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to get the PECL version of an extension.
|
||||
get_pecl_version() {
|
||||
local extension=$1
|
||||
|
@ -68,19 +68,13 @@ check_package() {
|
||||
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
||||
}
|
||||
|
||||
# Function to add extensions.
|
||||
add_extension() {
|
||||
# Helper function to add an extension.
|
||||
add_extension_helper() {
|
||||
local extension=$1
|
||||
prefix=$2
|
||||
package=php"$version"-"$extension"
|
||||
enable_extension "$extension" "$prefix"
|
||||
if check_extension "$extension"; then
|
||||
add_log "${tick:?}" "$extension" "Enabled"
|
||||
else
|
||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
fi
|
||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
||||
add_extension_log "$extension" "Installed and enabled"
|
||||
sudo chmod 777 "${ini_file[@]}"
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user