Skip to content

Instantly share code, notes, and snippets.

@bramadityaw
Created August 12, 2025 08:33
Show Gist options
  • Select an option

  • Save bramadityaw/6fb0721a3eb1b8bcfb21afe83458b21c to your computer and use it in GitHub Desktop.

Select an option

Save bramadityaw/6fb0721a3eb1b8bcfb21afe83458b21c to your computer and use it in GitHub Desktop.
Bash script to find artisan command inside a Laravel project
#!/usr/bin/env bash
wd="$PWD"
while [[ ! -e "$wd/artisan" ]]; do
if [[ "$wd" = "/" ]]; then
printf "artisan command not found: searched until $wd\n"
exit 1
fi
wd=${wd%/*}
[ -z "$wd" ] && wd="/"
done
[[ -e "$wd/artisan" ]] && {
f="$wd/artisan"
declare start_tag
read -r -n5 start_tag < "$f"
[[ "$start_tag" = "<?php" ]] && php $wd/artisan $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment