Skip to content

Commit

Permalink
Merge pull request #42 from ikari7789/patch-1
Browse files Browse the repository at this point in the history
Update for new PHP packages from Homebrew
  • Loading branch information
philcook authored Apr 4, 2018
2 parents 6fe9167 + ccec2f0 commit 530d5ae
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .travis/clean.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

for version in 53 54 55 56 70 71 72;
for version in '5.6' '7.0' '7.1' '7.2';
do
brew unlink php$version;
brew unlink php@$version;
done
25 changes: 9 additions & 16 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@

if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew update
brew install php53
brew unlink php53
brew install php54
brew unlink php54
brew install php55
brew unlink php55
brew install php56
brew unlink php56
brew install php70
brew unlink php70
brew install php71
brew unlink php71
brew install php72
brew unlink php72
brew install [email protected]
brew unlink [email protected]
brew install [email protected]
brew unlink [email protected]
brew install [email protected]
brew unlink [email protected]
brew install [email protected]
brew link --overwrite [email protected]
brew unlink [email protected]

echo 'Installed all PHP versions.'
fi
6 changes: 3 additions & 3 deletions .travis/test.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

error=0
for version in 53 54 55 56 70 71 72
for version in '5.6' '7.0' '7.1' '7.2'
do
. `echo $(dirname $0)"/../phpswitch.sh"` $version -s > /dev/null
switched=$(php -v | grep -e '^PHP' | cut -d' ' -f2 | cut -d. -f1,2 | sed 's/\.//')
if [ $version -ne $switched ];
switched=$(php -v | grep -e '^PHP' | cut -d' ' -f2 | cut -d. -f1,2)
if [ "$version" != "$switched" ];
then
error=1
echo -n 'E'
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you support multiple products/projects that are built using either brand new
Caveats
-------

For users of OSX only who have installed PHP via [Homebrew] and for PHP version 5.3, 5.4, 5.5, 5.6, 7.0, 7.1 and 7.2 only.
For users of OSX only who have installed PHP via [Homebrew] and for PHP version 5.6, 7.0, 7.1 and 7.2 only.

Your Apache config must have native osx PHP module commented out.
```sh
Expand Down Expand Up @@ -37,9 +37,9 @@ Installation
brew install brew-php-switcher
```

Where **56** exists, please replace with syntax of **53**, **54**, **55**, **56**, **70** or **71** or **72** depending on which version is required.
Where **5.6** exists, please replace with syntax of **5.6**, **7.0**, **7.1**, or **7.2** depending on which version is required.
```sh
brew-php-switcher 56
brew-php-switcher 5.6
```

> by default will switch apache config
Expand All @@ -51,25 +51,25 @@ Options

```sh
# skip apache only
brew-php-switcher 56 -s
brew-php-switcher 5.6 -s

# skip valet only
brew-php-switcher 56 -s=valet
brew-php-switcher 5.6 -s=valet

# skip valet & apache
brew-php-switcher 56 -s=valet,apache
brew-php-switcher 5.6 -s=valet,apache
```
- `-c=*` switch a specific config for i.e

```sh
# switch valet config only
brew-php-switcher 56 -c=valet
brew-php-switcher 5.6 -c=valet

# switch valet & apache config only
brew-php-switcher 56 -c=valet,apache
brew-php-switcher 5.6 -c=valet,apache

# switch apache config only
brew-php-switcher 56 -c=apache
brew-php-switcher 5.6 -c=apache
```

License
Expand Down
15 changes: 8 additions & 7 deletions phpswitch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# Twitter: @p_cook
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')

brew_array=("53","54","55","56","70","71","72")
php_array=("php53" "php54" "php55" "php56" "php70" "php71" "php72")
valet_support_php_version_array=("php56" "php70" "php71" "php72")
brew_array=("5.6","7.0","7.1","7.2")
php_array=("[email protected]" "[email protected]" "[email protected]" "[email protected]")
valet_support_php_version_array=("[email protected]" "[email protected]" "[email protected]" "[email protected]")
php_installed_array=()
php_version="php$1"
php_version="php@$1"
php_opt_path="$brew_prefix\/opt\/"

php5_module="php5_module"
Expand All @@ -31,7 +31,7 @@ then
exit
fi

if [ $(echo "$php_version" | sed 's/^php//') -ge 70 ]; then
if [ $(echo "$php_version" | sed 's/^php@//' | sed 's/\.//') -ge 70 ]; then
php_module="$php7_module"
apache_php_lib_path="$apache_php7_lib_path"
fi
Expand Down Expand Up @@ -110,7 +110,7 @@ then
brew unlink $i
fi
done
brew link "$php_version"
brew link --force "$php_version"

# Switch apache
if [[ $apache_change -eq 1 ]]; then
Expand All @@ -121,7 +121,7 @@ then
do
loop_php_module="$php5_module"
loop_apache_php_lib_path="$apache_php5_lib_path"
if [ $(echo "$j" | sed 's/^php//') -ge 70 ]; then
if [ $(echo "$j" | sed 's/^php@//' | sed 's/\.//') -ge 70 ]; then
loop_php_module="$php7_module"
loop_apache_php_lib_path="$apache_php7_lib_path"
fi
Expand Down Expand Up @@ -163,3 +163,4 @@ $comment_apache_module_string\\
else
echo "Unknown version of PHP. PHP Switcher can only handle arguments of:" ${brew_array[@]}
fi

0 comments on commit 530d5ae

Please sign in to comment.