File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ /.idea
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+
3+ declare -a php_versions
4+
5+ version=$( php -v | grep -o -e " PHP [0-9+]\.[0-9+]" | cut -d " " -f2)
6+ php_versions=($( brew ls --versions | grep -e " ^php" | cut -d " " -f2 | grep -o -e " [0-9+]\.[0-9+]" | xargs) )
7+
8+ if [ -z " $1 " ]; then
9+ php_versions=$( printf " , %s" " ${php_versions[@]} " )
10+
11+ echo " Usage: $0 <version>"
12+ echo " PHP Versions: ${php_versions: 2} "
13+ exit 0
14+ fi
15+
16+ version_found=0
17+ for php_version in ${php_versions[@]} ; do
18+ if [ " ${php_version} " = " $1 " ]; then
19+ version_found=1
20+ break
21+ fi
22+ done
23+
24+ if [ ${version_found} = 0 ]; then
25+ echo " Specified PHP version $1 is not installed."
26+ exit 1
27+ fi
28+
29+ if [ " ${version} " = " $1 " ]; then
30+ echo " Cannot change PHP to the same version."
31+ exit 1
32+ fi
33+
34+ apache_conf_file=$( apachectl -V | grep " SERVER_CONFIG_FILE" | cut -d ' "' -f 2)
35+ php_module=$( cat ${apache_conf_file} | grep -e " ^LoadModule" | grep " libphp" )
36+ new_php_module=$( brew info " php@$1 " | grep " LoadModule" | grep " libphp" | xargs)
37+
38+ sed -i " " " s#${php_module} #${new_php_module} #g" ${apache_conf_file}
39+ brew unlink php
40+ brew link " php@$1 " --force --overwrite
41+ brew services restart httpd
42+
43+ cp " ${apache_conf_file} " " ${apache_conf_file} .bak"
You can’t perform that action at this time.
0 commit comments