From 1ac1dee58cf2ddbd10b4bd37685638f875c58b2e Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 16 Aug 2021 14:53:10 +1000 Subject: [PATCH] Add link-brewed-php to help with PHP versioning Basically when you install multiple PHPs with Homebrew, they don't end up on PATH anywhere - you can brew link one of them, but that overwrites any other PHPs you might have previously linked. Other platforms, such as Ubuntu, package their PHPs such that a binary called something like php7.4 ends up on PATH. This is a much more helpful approach, since you can specifically invoke the necessary version of PHP by adding a version suffix. This script does the same thing for Homebrew-installed PHPs. Pretty simple. --- local/bin/link-brewed-php | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 local/bin/link-brewed-php diff --git a/local/bin/link-brewed-php b/local/bin/link-brewed-php new file mode 100755 index 0000000..11f6e72 --- /dev/null +++ b/local/bin/link-brewed-php @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh +cd ~/bin || exit $? +for bin in /usr/local/opt/php@*/bin/php; do + name=php${${bin##*@}%%/*} + echo "Linking ~/bin/$name -> $bin" >&2 + ln -fs $bin $name +done