jalendport / switch-php Goto Github PK
View Code? Open in Web Editor NEWEasily switch between PHP versions on your Mac. Requires Homebrew and works with Laravel Valet. π
Home Page: https://www.npmjs.com/package/switch-php
License: MIT License
Easily switch between PHP versions on your Mac. Requires Homebrew and works with Laravel Valet. π
Home Page: https://www.npmjs.com/package/switch-php
License: MIT License
Since homebrew installs [email protected]
as php
the switcher cannot interact anymore.
Temporary Workaround: running brew link --overwrite [email protected]
. Afterwards it's possible to switch between PHP version lower than v8
I'm running mac 10.13 High Sierra. My macos came with php7.1 installed, but I'm trying to use 7.3.
This is the outcome of "php -v" in terminal:
I've installed php 7.3 via HomeBrew and now whenever I try to swicth versions, I get this:
First it says that I'm already using php7.3 which is not true since my php -v
command returned php 7.1.
Second, it says that is starting php7.3 and immediately returns saying that I am now using php7.1.
Any ideas as to why this is happening?
Hi!
PHP 7.3 already stable
I love the idea for this but I can't seem to get it to work correctly. I originally had only PHP 7.1 installed with Homebrew and I use Valet... To test the script I went ahead and just now installed 7.2 with Homebrew then tried to switch:
> switch-php 72 -v -m 512M
π Verifying that Valet is installed...
Password:
π Checking which PHP versions are installed...
π Stopping Valet...
==> Stopping nginx...
β
Valet stopped
π Switching to php72...
==> Stopping php71...
==> Unlinking php71...
==> Stopping php72...
==> Unlinking php72...
==> Linking php72...
==> Starting php72...
β
PHP switched
β Starting Valet...
==> Starting nginx...
==> Starting dnsmasq...
β
Valet started
π Configuring PHP...
==> Setting PHP memory to 512M...
==> Restarting PHP...
β
PHP configured
You are now using PHP 7.1.14
Bug? Did I maybe not install 7.2 correctly? I installed 7.2 with brew install php72 php72-igbinary php72-imagick php72-memcached
Update this for support php 7.4 please and thanks!
Could you please tag a release with the PHP 7.4 support?
I have Brew installed already so all good, but I think it would be nice to check for Brew in case user forgot that he/she does not have Brew installed.
Something like this perhaps?
command -v brew >/dev/null 2>&1 || { echo >&2 "Installing Homebrew Now"; \
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; }
Source: https://gist.github.com/ryanmaclean/4094dfdbb13e43656c3d41eccdceae05
Could be a nice feature to add to the scripts.
Hey there!
When I try and switch from php 7.4.5, nothing seems to happen.
brett~/Sites$ switch-php 7.1
Password:
Valet stopped β
PHP switched β
Valet started β
You are now using PHP 7.4.5
I'd expect PHP 7.1 to be in use after running this.
thanks for this great work,
gut what theme are you using in your gif in the readme file
I stumbled across this software when looking through random twitter posts. Since homebrew recently merged all the php formulas in to the core distribution you might want to consider changing the formula names to the new ones.
I've installed imagemagick
php
and [email protected]
switch-php 7.3
PHP switched β
You are now using PHP 7.3.4
switch-php 7.2
PHP switched β
PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20170718/imagick.so (dlopen(/usr/local/lib/php/pecl/20170718/imagick.so, 9): image not found), /usr/local/lib/php/pecl/20170718/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20170718/imagick.so.so, 9): image not found)) in Unknown on line 0
You are now using PHP
Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/pecl/20170718/imagick.so (dlopen(/usr/local/lib/php/pecl/20170718/imagick.so, 9): image not found), /usr/local/lib/php/pecl/20170718/imagick.so.so (dlopen(/usr/local/lib/php/pecl/20170718/imagick.so.so, 9): image not found)) in Unknown on line 0
7.2.17
How do I have imagemagick work for both 7.3 and 7.2
I have [email protected] and [email protected] installed with brew. Running php switcher gives the following:
$ switch-php 5.6 -v
π Verifying that Valet is installed...
Password:
π Checking which PHP versions are installed...
π Stopping Valet...
==> Stopping nginx...
β
Valet stopped
π Switching to [email protected]...
==> Stopping [email protected]...
==> Unlinking [email protected]...
==> Stopping [email protected]...
==> Unlinking [email protected]...
==> Linking [email protected]...
==> Starting [email protected]...
β
PHP switched
β Starting Valet...
==> Starting nginx...
β
Valet started
You are now using PHP 7.1.20
Showing the version gives php 7.1.20
php -v
PHP 7.1.20 (cli) (built: Jul 20 2018 10:27:12) ( NTS )
Exited terminal, restarted and reading the #2 issue fired the following:
$ brew link --overwrite php
Error: No such keg: /usr/local/Cellar/php
Brew doctor:
Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/bin/php
Then tried manually unlink 7.1:
$ brew unlink [email protected]
Unlinking /usr/local/Cellar/[email protected]/7.1.20... 0 symlinks removed
and relink 5.6:
$Β brew link --overwrite --force [email protected]
Linking /usr/local/Cellar/[email protected]/5.6.37... 25 symlinks created
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
..but phpinfo() show me 7.1.20 yet
When platform is specified in composer.json
, this should be used for switch-php (possibly abbreviated to minor level).
This should work analog to nvm
by not specifying any further arguments.
Macbook Bro - Mojave
β ~ switch-php 7.3
Password:
Valet stopped β
PHP switched β
Valet started β
You are now using PHP 7.2.11
I also restarted terminal to make sure but it didn't
$ switch-php 7.2
PHP switched β
You are now using PHP 5.4.45
$ which php
/usr/local/bin/php
$ php --version
PHP 5.4.45 (cli) (built: Nov 9 2017 14:09:48)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
I assume it's because my PHP is not installed via brew. It'd be nice if the tool can show error instead of saying it was successful
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.