Created
December 29, 2025 10:46
-
-
Save patarok/e6a312b5205ea21a5ed32e8180d621ea to your computer and use it in GitHub Desktop.
Call php artisan from everywhere inside your project... add that to your .bashrc
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
| # 1. Define the logic | |
| find_artisan() { | |
| local path=$(pwd) | |
| while [[ "$path" != "" && ! -e "$path/artisan" ]]; do | |
| path=${path%/*} | |
| done | |
| if [[ -e "$path/artisan" ]]; then | |
| if [[ -e "$path/.env" ]]; then | |
| php "$path/artisan" "$@" | |
| else | |
| echo "Found artisan file at $path, but no .env file found. Safety stop." | |
| fi | |
| else | |
| echo "Error: No Laravel artisan file found in this directory or any parent." | |
| fi | |
| } | |
| # 2. Assign the aliases to use that logic | |
| alias artisan='find_artisan' | |
| alias pa='find_artisan' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment