Skip to content

Instantly share code, notes, and snippets.

@glensc
Last active August 23, 2022 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glensc/405108d6f175a3d202dee8fd507ef5da to your computer and use it in GitHub Desktop.
Save glensc/405108d6f175a3d202dee8fd507ef5da to your computer and use it in GitHub Desktop.
brew and phpXY in PATH
#!/bin/sh
set -e
dir=$(dirname "$0")
for php in \
/usr/local/opt/php/bin/php \
/opt/homebrew/opt/php/bin/php \
/usr/local/Cellar/php*/*/bin/php \
/usr/local/opt/php@*/bin/php \
/opt/homebrew/opt/php@*/bin/php \
; do
version=$($php -d display_errors=off -r 'echo PHP_MAJOR_VERSION, PHP_MINOR_VERSION;' 2>/dev/null) || continue
target="$dir/php$version"
ln -snf "$php" "$target"
ls -ld "$target"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment