When switching between different PHP projects (or different branches of one PHP project), you often need to switch PHP versions. Particularly as older libraries will not run on newer versions of PHP. After losing patience with how the otherwise excellent Homebrew handles this, I stumbled upon this super-useful tool: switch-php.
This seems to have been written for PHP developers and integrates brilliantly with Laravel Valet. Here’s an example of switching from PHP 7.3 to 7.2:
$ php -v PHP 7.3.0 (cli) (built: Dec 7 2018 11:00:11) ( NTS ) Copyright (c) 1997-2018 The PHP Group $ switch-php 7.2 Valet stopped ✔ PHP switched ✔ Valet started ✔ You are now using PHP 7.2.13 $ php -v PHP 7.2.13 (cli) (built: Dec 7 2018 10:41:23) ( NTS ) Copyright (c) 1997-2018 The PHP Group