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,14 +78,10 @@ add_brew_extension() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup extensions.
|
# Helper function to add an extension.
|
||||||
add_extension() {
|
add_extension_helper() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
prefix=$2
|
prefix=$2
|
||||||
enable_extension "$extension" "$prefix"
|
|
||||||
if check_extension "$extension"; then
|
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
|
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
|
||||||
run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
|
run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
@ -93,7 +89,6 @@ add_extension() {
|
|||||||
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
||||||
fi
|
fi
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to handle request to add phpize and php-config.
|
# Function to handle request to add phpize and php-config.
|
||||||
|
@ -109,6 +109,18 @@ configure_pecl() {
|
|||||||
fi
|
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.
|
# Function to get the PECL version of an extension.
|
||||||
get_pecl_version() {
|
get_pecl_version() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
|
@ -68,19 +68,13 @@ check_package() {
|
|||||||
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add extensions.
|
# Helper function to add an extension.
|
||||||
add_extension() {
|
add_extension_helper() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
prefix=$2
|
|
||||||
package=php"$version"-"$extension"
|
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
|
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||||
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
fi
|
|
||||||
sudo chmod 777 "${ini_file[@]}"
|
sudo chmod 777 "${ini_file[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user