2021-02-16 12:36:23 +07:00
|
|
|
# Function to get http version for a PHP version.
|
|
|
|
get_http_version() {
|
|
|
|
if [[ ${version:?} =~ 5.[3-6] ]]; then
|
|
|
|
echo "pecl_http-2.6.0"
|
|
|
|
elif [[ ${version:?} =~ 7.[0-4] ]]; then
|
|
|
|
echo "pecl_http-3.2.4"
|
|
|
|
else
|
|
|
|
echo "pecl_http-$(get_pecl_version "pecl_http" "stable")"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to enable http extension.
|
|
|
|
enable_http() {
|
2022-03-15 12:58:20 +07:00
|
|
|
enable_extension iconv extension
|
2021-02-16 12:36:23 +07:00
|
|
|
enable_extension propro extension
|
|
|
|
enable_extension raphf extension
|
2022-03-15 12:58:20 +07:00
|
|
|
if (! [[ ${version:?} =~ ${jit_versions:?} ]] && check_extension iconv && check_extension propro && check_extension raphf) ||
|
|
|
|
( [[ ${version:?} =~ ${jit_versions:?} ]] && check_extension iconv && check_extension raphf); then
|
2021-02-16 12:36:23 +07:00
|
|
|
enable_extension http extension
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-04-03 06:43:18 +07:00
|
|
|
# Function to install http dependencies.
|
|
|
|
add_http_dependencies() {
|
|
|
|
if [[ ${version:?} =~ ${old_versions:?} ]]; then
|
2021-02-16 12:36:23 +07:00
|
|
|
add_pecl_extension raphf 1.1.2 extension
|
|
|
|
add_pecl_extension propro 1.0.2 extension
|
2021-04-03 06:43:18 +07:00
|
|
|
elif [[ ${version:?} =~ 5.6|7.[0-4] ]]; then
|
2022-03-15 12:58:20 +07:00
|
|
|
add_extension iconv extension
|
|
|
|
add_extension propro extension
|
|
|
|
add_extension raphf extension
|
2021-02-16 12:36:23 +07:00
|
|
|
else
|
2022-03-15 12:58:20 +07:00
|
|
|
add_extension iconv extension
|
|
|
|
add_extension raphf extension
|
2021-02-16 12:36:23 +07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to get configure options for http.
|
|
|
|
get_http_configure_opts() {
|
|
|
|
if [ "$os" = 'Linux' ]; then
|
|
|
|
for lib in zlib libbrotli libcurl libevent libicu libidn2 libidn libidnkit2 libidnkit; do
|
|
|
|
http_opts+=( "--with-http-$lib-dir=/usr" )
|
|
|
|
done
|
|
|
|
else
|
|
|
|
http_opts+=( "--with-http-zlib-dir=$(xcrun --show-sdk-path)/usr" )
|
|
|
|
http_opts+=( "--with-http-libbrotli-dir=$(brew --prefix brotli)" )
|
|
|
|
http_opts+=( "--with-http-libcurl-dir=$(brew --prefix curl)" )
|
|
|
|
http_opts+=( "--with-http-libicu-dir=$(brew --prefix icu4c)" )
|
|
|
|
http_opts+=( "--with-http-libevent-dir=$(brew --prefix libevent)" )
|
|
|
|
http_opts+=( "--with-http-libidn2-dir=$(brew --prefix libidn2)" )
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Compile and install http explicitly.
|
|
|
|
# This is done as pecl compiles raphf and propro as well.
|
|
|
|
add_http_helper() {
|
|
|
|
ext=$1
|
2021-04-03 06:43:18 +07:00
|
|
|
http_opts=() && get_http_configure_opts
|
|
|
|
export HTTP_PREFIX_CONFIGURE_OPTS="CFLAGS=-Wno-implicit-function-declaration"
|
|
|
|
http_configure_opts="--with-http --with-php-config=$(command -v php-config) ${http_opts[*]}"
|
|
|
|
export HTTP_CONFIGURE_OPTS="$http_configure_opts"
|
|
|
|
export HTTP_LINUX_LIBS="zlib1g libbrotli-dev libcurl4-openssl-dev libevent-dev libicu-dev libidn2-dev"
|
|
|
|
export HTTP_DARWIN_LIBS="brotli curl icu4c libevent libidn2"
|
|
|
|
if [[ "${version:?}" =~ ${nightly_versions:?} ]]; then
|
2021-04-19 18:33:57 +07:00
|
|
|
add_extension_from_source http https://github.com m6w6 ext-http master extension
|
2021-04-03 06:43:18 +07:00
|
|
|
else
|
2021-04-19 18:33:57 +07:00
|
|
|
add_extension_from_source pecl_http https://pecl.php.net http http "${ext##*-}" extension pecl
|
2021-04-03 06:43:18 +07:00
|
|
|
fi
|
2021-02-16 12:36:23 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
# Function to setup latest http extension.
|
|
|
|
add_http_latest() {
|
|
|
|
enable_http
|
|
|
|
if ! check_extension http; then
|
|
|
|
if [ "$os" = "Linux" ]; then
|
2022-01-31 20:46:13 +07:00
|
|
|
add_http_dependencies
|
2021-12-20 21:05:45 +07:00
|
|
|
package="php$version-http"
|
|
|
|
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
|
|
(check_package "$package" && install_packages "$package") || add_http_helper "$(get_http_version)" "$os"
|
2021-02-16 12:36:23 +07:00
|
|
|
else
|
|
|
|
if ! [[ "${version:?}" =~ ${old_versions:?} ]]; then
|
|
|
|
add_brew_extension pecl_http extension
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
status="Installed and enabled"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to setup http extension given a version.
|
|
|
|
add_http_version() {
|
|
|
|
ext=$1
|
|
|
|
enable_http
|
|
|
|
if [ "x$(php -r "echo phpversion('http');")" != "x${ext##*-}" ]; then
|
2021-08-24 17:44:52 +07:00
|
|
|
disable_extension_helper http >/dev/null
|
2021-02-16 12:36:23 +07:00
|
|
|
add_http_helper pecl_http-"${ext##*-}" "$os"
|
|
|
|
status="Installed and enabled"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to setup http extension
|
|
|
|
add_http() {
|
|
|
|
ext=$1
|
|
|
|
status="Enabled"
|
|
|
|
if [[ "$ext" =~ ^(pecl_http|http)$ ]]; then
|
2021-04-03 06:43:18 +07:00
|
|
|
add_http_latest >/dev/null 2>&1
|
2021-02-16 12:36:23 +07:00
|
|
|
else
|
2021-04-03 06:43:18 +07:00
|
|
|
add_http_version "$ext" >/dev/null 2>&1
|
2021-02-16 12:36:23 +07:00
|
|
|
fi
|
|
|
|
add_extension_log "http" "$status"
|
|
|
|
}
|
2021-04-03 06:43:18 +07:00
|
|
|
|
|
|
|
os="$(uname -s)"
|