Created
August 12, 2025 08:33
-
-
Save bramadityaw/6fb0721a3eb1b8bcfb21afe83458b21c to your computer and use it in GitHub Desktop.
Bash script to find artisan command inside a Laravel project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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