Skip to content

Commit

Permalink
Merge pull request #2 from shivammathur/develop
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
shivammathur authored Mar 8, 2020
2 parents fa13da0 + 64515db commit 5613aa6
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 28 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
run:
runs-on: macos-latest
Expand All @@ -21,8 +26,21 @@ jobs:
bash install.sh ${version/./}
- name: Testing PHP version
run: |
php --ini
php -v
phpize --version
php-config --version
php -r "if(strpos(phpversion(), '${{ matrix.php-versions }}') === false) {throw new Exception('Wrong PHP version Installed');}"
- name: Testing
- name: Testing PHP extensions
run: |
php -m
php -m
version=${{ matrix.php-versions }}
for bin in /tmp/php"${version/./}"/ext/*.so; do
extension=$(basename "$bin" | cut -d'.' -f 1)
php -r "if(! extension_loaded('$extension')) {throw new Exception('$extension not found');}"
done
php -r "if(! extension_loaded('Zend OPcache')) {throw new Exception('Zend OPcache not found');}"
- name: Testing PECL version
run: pecl -V
- name: Testing SSL in file_get_contents
run: php -r "echo file_get_contents('https://repo.packagist.org/packages.json');"
80 changes: 54 additions & 26 deletions install.sh
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

0 comments on commit 5613aa6

Please sign in to comment.