Skip to content

Instantly share code, notes, and snippets.

@patarok
Created December 29, 2025 10:46
Show Gist options
  • Select an option

  • Save patarok/e6a312b5205ea21a5ed32e8180d621ea to your computer and use it in GitHub Desktop.

Select an option

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
# 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