-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from shivammathur/develop
1.0.0
- Loading branch information
Showing
2 changed files
with
74 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,55 @@ | ||
version=$1 | ||
php_version="php$version" | ||
ini_file="/opt/local/etc/php$version/php.ini" | ||
github_link="https://github.com/" | ||
github_repo="$github_link/shivammathur/php5-darwin" | ||
php_etc_dir="/opt/local/etc/php$version" | ||
tmp_path="/tmp/php$version" | ||
export TERM=xterm | ||
curl -o /tmp/php$1.tar.xz -sSL https://github.com/shivammathur/php5-darwin/releases/latest/download/php"$1".tar.xz | ||
sudo tar xf /tmp/php$1.tar.xz -C /tmp | ||
sudo installer -pkg /tmp/php$1/php$1.mpkg -target / | ||
sudo cp /opt/local/etc/php$1/php.ini-development /opt/local/etc/php$1/php.ini | ||
sudo mv /opt/local/bin/php$1 /opt/local/bin/php | ||
sudo mv /opt/local/bin/phpize$1 /opt/local/bin/phpize | ||
sudo mv /opt/local/bin/php-config$1 /opt/local/bin/php-config | ||
sudo ln -sf /opt/local/bin/* /usr/local/bin | ||
ext_dir=$(php -d "date.timezone=UTC" -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") | ||
ini_file=/opt/local/etc/php"$1"/php.ini | ||
sudo chmod 777 "$ini_file" | ||
echo "date.timezone=UTC" >>"$ini_file" | ||
sudo mkdir -p $ext_dir | ||
sudo cp -a /tmp/php$1/lib/* /opt/local/lib | ||
sudo cp -a /tmp/php$1/ext/*.so $ext_dir | ||
for bin in /tmp/php$1/ext/*.so; do | ||
extension=$(basename $bin | cut -d'.' -f 1) | ||
echo "extension=$extension.so" >>"$ini_file" | ||
done | ||
sudo installer -pkg /tmp/php$1/php$1-opcache.pkg -target / | ||
pecl_version='master' | ||
if [ "$1" = "53" ]; then | ||
pecl_version='v1.9.5' | ||
fi | ||
sudo curl -o /tmp/pear.phar -sSL https://github.com/pear/pearweb_phars/raw/$pecl_version/install-pear-nozlib.phar | ||
sudo php /tmp/pear.phar -d /opt/local/lib/php$1 -b /usr/local/bin | ||
|
||
# Function to switch PHP version | ||
switch_version() { | ||
for tool in php phpize php-config; do | ||
sudo mv /opt/local/bin/"$tool$version" /opt/local/bin/"$tool" | ||
done | ||
sudo ln -sf /opt/local/bin/* /usr/local/bin | ||
} | ||
|
||
# Function to setup PHP | ||
setup_php() { | ||
curl -o "$tmp_path".tar.xz -sSL "$github_repo"/releases/latest/download/"$php_version".tar.xz | ||
sudo tar xf "$tmp_path".tar.xz -C /tmp | ||
sudo installer -pkg "$tmp_path"/"$php_version".mpkg -target / | ||
sudo cp -a "$tmp_path"/lib/* /opt/local/lib | ||
sudo cp "$php_etc_dir"/php.ini-development "$php_etc_dir"/php.ini | ||
sudo chmod 777 "$ini_file" | ||
echo "date.timezone=UTC" >>"$ini_file" | ||
} | ||
|
||
# Function to add extensions | ||
add_extensions() { | ||
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") | ||
sudo mkdir -p "$ext_dir" | ||
sudo cp -a "$tmp_path"/ext/*.so "$ext_dir" | ||
sudo installer -pkg "$tmp_path"/"$php_version"-opcache.pkg -target / | ||
for bin in "$tmp_path"/ext/*.so; do | ||
extension=$(basename "$bin" | cut -d'.' -f 1) | ||
echo "extension=$extension.so" >>"$ini_file" | ||
done | ||
} | ||
|
||
# Function to add pear | ||
add_pear() { | ||
pecl_version='master' | ||
if [ "$version" = "53" ]; then | ||
pecl_version='v1.9.5' | ||
fi | ||
pear_github_repo="$github_link/pear/pearweb_phars" | ||
sudo curl -o /tmp/pear.phar -sSL "$pear_github_repo/raw/$pecl_version/install-pear-nozlib.phar" | ||
sudo php /tmp/pear.phar -d /opt/local/lib/"$php_version" -b /usr/local/bin | ||
} | ||
|
||
setup_php | ||
switch_version | ||
add_extensions | ||
add_pear |