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
2020-10-12 12:15:03 +07:00
if [ " $extension " = "phalcon4" ] ; then
${ apt_install : ? } " php ${ version : ? } -psr " " php ${ version : ? } - $extension "
else
2021-02-22 20:10:19 +07:00
get -q -e /tmp/phalcon.deb " https://packagecloud.io/phalcon/stable/packages/ubuntu/bionic/php ${ version : ? } -phalcon_3.4.5-1+php ${ version : ? } _amd64.deb/download.deb "
sudo dpkg -i /tmp/phalcon.deb
2020-10-12 12:15:03 +07:00
fi
2020-01-21 19:28:09 +07:00
else
2020-07-26 17:18:19 +07:00
sed -i '' '/extension.*psr/d' " ${ ini_file : ? } "
2021-02-22 20:10:19 +07:00
add_brew_tap shivammathur/homebrew-phalcon
2020-07-26 17:18:19 +07:00
brew install phalcon@" ${ version : ? } " _" $extension_major_version "
2021-02-22 20:10:19 +07:00
sudo cp " ${ brew_prefix : ? } " /opt/psr@" ${ version : ? } " /psr.so " ${ ext_dir : ? } "
sudo cp " ${ brew_prefix : ? } " /opt/phalcon@" ${ version : ? } " _" $extension_major_version " /phalcon.so " ${ ext_dir : ? } "
2020-01-21 19:28:09 +07:00
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 "
2020-07-23 07:19:11 +07:00
fi
2020-07-26 17:18:19 +07:00
else
add_phalcon_helper
2020-12-02 07:20:56 +07:00
fi
2020-01-21 19:28:09 +07:00
}
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 : ? } "
2020-01-21 19:28:09 +07:00
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)
2020-01-21 19:28:09 +07:00
if [ " $phalcon_version " != " $extension_major_version " ] ; then
2020-07-26 17:18:19 +07:00
add_phalcon_helper
2020-01-21 19:28:09 +07:00
else
2020-07-26 17:18:19 +07:00
echo "extension=phalcon.so" | sudo tee -a " $phalcon_ini_file "
2020-01-21 19:28:09 +07:00
fi
else
2020-07-26 17:18:19 +07:00
add_phalcon_helper
2019-12-31 14:55:59 +07:00
fi
2020-01-21 19:28:09 +07:00
else
2020-07-26 17:18:19 +07:00
add_phalcon_helper
2020-12-02 07:20:56 +07:00
fi
2020-07-26 17:18:19 +07:00
}
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)
2020-12-02 07:20:56 +07:00
phalcon_ini_file = " ${ pecl_file :- ${ ini_file [@] } } "
2020-07-26 17:18:19 +07:00
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
2020-01-21 19:28:09 +07:00
fi
2020-07-26 17:18:19 +07:00
add_extension_log "phalcon" " $status "
}