Skip to content
프로젝트

소개

zsh용 Laravel Artisan 플러그인으로, 프로젝트 트리 어디에서나 Artisan을 실행할 수 있으며 자동 완성을 지원합니다. Artisan이 생성한 파일을 자동으로 열 수도 있습니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
-2
in 15 days
-1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

zsh-artisan - Enhanced Laravel integration for zsh

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.

Requirements

Installation

Antigen

Add the following bundle to your .zshrc:

antigen bundle jessarcher/zsh-artisan

Fig

Fig adds apps, shortcuts, and autocomplete to your existing terminal.

Install artisan in just one click.

Oh-my-zsh

First download the plugin to your oh-my-zsh custom plugin location:

git clone https://github.com/jessarcher/zsh-artisan.git "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/artisan

Note that the repository name is prefixed with zsh-, however the plugin directory name should just be "artisan".

Then enable the plugin in your .zshrc file. For example:

plugins=(
    artisan
    composer
    git
)

zplug

Add the following to your .zshrc:

zplug "jessarcher/zsh-artisan"

Configuration

If you wish to automatically open new files created by artisan make:* commands then you will need to configure the ARTISAN_OPEN_ON_MAKE_EDITOR environment variable. The best place for this is probably your .zshrc file. For example:

ARTISAN_OPEN_ON_MAKE_EDITOR=vim
#ARTISAN_OPEN_ON_MAKE_EDITOR=subl   # Sublime Text
#ARTISAN_OPEN_ON_MAKE_EDITOR=pstorm # PHPStorm
#ARTISAN_OPEN_ON_MAKE_EDITOR=atom   # Atom (May require shell commands to be enabled)
#ARTISAN_OPEN_ON_MAKE_EDITOR=code   # VSCode (May require shell commands to be enabled)

The author uses mhinz/neovim-remote, combined with a wrapper script, to automatically open files in an existing neovim session within the same tmux session, and automatically switch to the correct tmux window (tab).

Note that you will need to re-source your .zshrc or restart zsh to pick up the changes.

Usage

Simply use the command artisan from anywhere within the directory structure of a Laravel project and it will search up the tree for the artisan command and execute it. E.g:

$ pwd
~/MyProject/tests/Feature

$ artisan make:model MyAwesomeModel
Model created successfully.

Tab-completion will work anywhere that artisan can be found, and the available commands are retrieved on-demand. This means that you will see any Artisan commands that are available to you, including any custom commands that have been defined.

If you configured the ARTISAN_OPEN_ON_MAKE_EDITOR environment variable, any files created by artisan make:* commands should automatically be opened, including when multiple files are created (E.g. by artisan make:model -m -c -r)

The plugin does not create any aliases for you, but the author would like to offer some suggestions:

alias a="artisan"
alias tinker="artisan tinker"
alias serve="artisan serve"

Many more can be found at https://laravel-news.com/bash-aliases

Homestead Setup

The Zsh Artisan plugin can be installed automatically with any new or provisioned Laravel Homestead instance. In the root of your Homestead project, add the following to your after.sh file.

ARTISAN=/home/vagrant/.oh-my-zsh/custom/plugins/artisan
if [ -d "$ARTISAN" ]; then
  echo "$ARTISAN exist"
else
  git clone https://github.com/jessarcher/zsh-artisan.git $ARTISAN
  sed -i 's/plugins=(git)/plugins=(git composer artisan)/g' /home/vagrant/.zshrc
  source /home/vagrant/.zshrc
fi

Note: If you are re-provisioning your Homestead box, and already have other Zsh plugins defined in your Zsh config files, you wil need to adjust the sed command to includes those in the list.

License

This project is open-sourced software licensed under the MIT License - see the LICENSE file for details

Acknowledgements

  • antonioribeiro/artisan-anywhere for some of the initial artisan location logic
  • The laravel5 plugin that comes with oh-my-zsh for the initial completion logic
  • ahuggins/open-on-make for the "open on make" functionality idea. Unfortunately, adding a dev dependency like this isn't an option on some of the projects I work on.

관련 프로젝트 살펴보기

불러오는 중…