setup-php/src/scripts/ext/phalcon.sh

66 lines
2.0 KiB
Bash
Raw Normal View History

2020-07-26 17:18:19 +07:00
# Helper function to add phalcon.
add_phalcon_helper() {
status='Installed and enabled'
if [ "$os_name" = "Linux" ]; then
update_lists
${apt_install:?} "php${version:?}-$extension"
else
2020-07-26 17:18:19 +07:00
phalcon_ini_file=${ini_file:?}
sed -i '' '/extension.*psr/d' "${ini_file:?}"
brew tap shivammathur/homebrew-phalcon
brew install phalcon@"${version:?}"_"$extension_major_version"
sudo cp /usr/local/opt/psr@"${version:?}"/psr.so "${ext_dir:?}"
sudo cp /usr/local/opt/phalcon@"${version:?}"_"$extension_major_version"/phalcon.so "${ext_dir:?}"
fi
}
2020-07-26 17:18:19 +07:00
# Function to add phalcon3.
add_phalcon3() {
if [ -e "${ext_dir:?}/phalcon.so" ]; then
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major_version" ]; then
add_phalcon_helper
else
echo "extension=phalcon.so" | sudo tee -a "$phalcon_ini_file"
fi
2020-07-26 17:18:19 +07:00
else
add_phalcon_helper
fi
}
2020-07-26 17:18:19 +07:00
# Function to add phalcon4.
add_phalcon4() {
if [ -e "${ext_dir:?}/psr.so" ] && ! php -m | grep -i -q -w psr; then
echo "extension=psr.so" | sudo tee -a "${ini_file:?}"
fi
if [ -e "$ext_dir/phalcon.so" ]; then
if php -m | grep -i -q -w psr; then
2020-02-02 16:53:02 +07:00
phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major_version" ]; then
2020-07-26 17:18:19 +07:00
add_phalcon_helper
else
2020-07-26 17:18:19 +07:00
echo "extension=phalcon.so" | sudo tee -a "$phalcon_ini_file"
fi
else
2020-07-26 17:18:19 +07:00
add_phalcon_helper
fi
else
2020-07-26 17:18:19 +07:00
add_phalcon_helper
fi
}
2019-10-27 07:12:49 +07:00
2020-07-26 17:18:19 +07:00
# Function to add phalcon.
add_phalcon() {
extension=$1
status='Enabled'
os_name=$(uname -s)
phalcon_ini_file="${scan_dir:?}/50-phalcon.ini"
extension_major_version=${extension: -1}
if [ "$extension_major_version" = "4" ]; then
add_phalcon4 >/dev/null 2>&1
elif [ "$extension_major_version" = "3" ]; then
add_phalcon3 >/dev/null 2>&1
fi
2020-07-26 17:18:19 +07:00
add_extension_log "phalcon" "$status"
}