If you are a user of zsh and you want to make it easier to use artisan commands, then just install the zsh-artisan plugin.

This plugin adds an artisan shell command with the following features:

  • It will find and execute artisan from anywhere within the project file tree (and you don't need to prefix it with php or ./)
  • It provides auto-completion for artisan commands (that also work anywhere within the project).
  • You can specify an editor to automatically open new files created by artisan make:* commands
  • It automatically runs artisan commands using sail when appropriate.
  • It will run commands using docker compose (or docker-compose) if a known container name is found.

zsh-artisan in action

Installation instructions can be found here.