This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php.sh
executable file
·86 lines (60 loc) · 2.32 KB
/
php.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
readonly phpswitch_executable="/usr/local/bin/phpswitch"
get_php_ini() {
echo `php -i 2> /dev/null | grep 'Loaded Configuration File' | sed 's/Loaded Configuration File => //'`
}
switch_version() {
local -r php_version="${1}"
phpswitch "${php_version}" -s=valet,apache
local -r extension_dir=`php-config --extension-dir`
# try our best to have a correct pear/pecl setup
pear config-set php_ini "$(get_php_ini)"
pear config-set ext_dir "${extension_dir}"
}
extension_install() {
local -r extension="${1}"
printf "\n" | pecl install "${extension}"
}
extension_uninstall() {
local -r extension="${1}"
# try to remove extension so we have a clean base
pecl uninstall "${extension}"
local -r search='/extension="'"${extension%-*}"'/d'
# pecl fails to remove the extension from the ini
sed -i '' "${search}" "$(get_php_ini)"
}
memcached_install() {
local -r memcached_source="${1}"
readonly ini_dir=`php -i | grep 'Scan this dir for additional .ini files' | sed 's/Scan this dir for additional .ini files => //'`
readonly build_dir=`mktemp --tmpdir -d 'tmp.memcached.XXXXXXX'`
cd "${build_dir}"
curl -#L "${memcached_source}" | tar -xv --strip-components 1 --exclude={README.md,LICENSE}
phpize
./configure --enable-memcached-igbinary --enable-memcached-json
make
make install
echo "extension=\"memcached.so\"" > "${ini_dir}/memcached.ini"
}
echo "------------------------------"
echo "Running PHP module"
echo "------------------------------"
echo ""
# xcode zlib is required for the memcached extension
if [[ -z $(xcode-select -p) ]]; then
echo "------------------------------"
echo "Installing Xcode Command Line Tools."
xcode-select --install
fi
echo "------------------------------"
echo "Installing brew dependencies"
brew bundle install -v --file="./brewfile"
echo "------------------------------"
echo "Installing php version switcher..."
curl -fsSL https://github.com/raw/philcook/brew-php-switcher/master/phpswitch.sh > "${phpswitch_executable}"
chmod +x "${phpswitch_executable}"
echo "------------------------------"
echo "Installing PHP 5.6 extensions..."
( source "./php56_extensions.sh" )
echo "------------------------------"
echo "Installing PHP 7.2 extensions..."
( source "./php72_extensions.sh" )