Skip to content

Instantly share code, notes, and snippets.

@davidalger
Last active March 20, 2023 19:20
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 davidalger/bdfad83558313b283ff1 to your computer and use it in GitHub Desktop.
Save davidalger/bdfad83558313b283ff1 to your computer and use it in GitHub Desktop.
Magento 2 Shell Wrapper
#!/usr/bin/env bash
# usage: put at /usr/local/bin/magento then call from anywhere within a magento 2 webroot
#
dir="$(pwd)"
while [[ "$dir" != "/" ]]; do
if [[ -x "$dir/bin/magento" ]]; then
"$dir/bin/magento" "$@"
exit $?
fi
dir="$(dirname "$dir")"
done
>&2 echo "Error: Failed to locate bin/magento (you probably are not inside a magento site root)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment