macOS: Simple PHP Switcher

Reading time ~1 minute

Recently I’ve been working with PHP applications in varying states of modernity/antiquity, and very regularly have to switch the current PHP version to accomodate the PHP flavors of the day. Homebrew un/link commands are super simple and at this point all I want is to be able to switch the PHP version with a single command. With a little bit of searching, I found a script that comes pretty close to what I need:

I made a fork, and then removed Apache stuff and unused code, converted conditionals to guard clauses, ran the remainder through shellcheck, and addressed a couple of minor consistency/grammar issues to achieve the following result:

comments powered by Disqus