Handy Aliases for Laravel Development
CLI Commands on Steroids
When working with Laravel, you have to use your CLI tool pretty much. I found I was running long commands several times, so I made some handy aliases for them, to quickly run long commands with small abbreviations.
The CLI tool I use is iTerm with Oh My Zsh. Especially Oh My Zsh adds a lot of awesomeness. One I like to most is that you don’t have a capitalize folders and files in the CLI, just hit tab
, and the folder or file name will be completed.
Aliases
alias art='php artisan'
I know some people have other aliases for php artisan
. My friends use part (p[hp] art[isan])
. And Freek van der Herten made the alias the smallest possible: a
.
alias vu='vagrant up'
alias hs='homestead'
alias hsp='homestead provision'
alias hsu='homestead up'
alias ci='composer install'
alias cu='composer update'
alias cdo='composer dump-autoload -o'
Sometimes we need a fresh autoloader, optimized.
alias amr='php artisan migrate:refresh'
alias ams='php artisan migrate --seed'
alias amrs=’php artisan migrate:refresh --seed'
When I want a clean database, I run this command. It rollbacks the database, runs the migrations and then seeds the database.
alias ybi='yarn install && bower install’
Yarn is a very nice tool, but it installs all packages from bower.json
in the node_modules
folder. Most of the time, that’s not a problem, but some of my/our projects, still rely on the bower_components
folder.
alias ybu='yarn upgrade && bower update'
alias gw='gulp watch'
alias ggw='gulp && gulp watch'
Instead of running gulp
and then gulp watch
, I just run this command, so I’m ready to go.
That’s nice, but how to use?
To use an alias, add it to your .bash_profile file (or .zshrc, when you’re also using Oh My Zsh), like so: alias art='php artisan'
. Don’t forget to close your active CLI tab, only newly opened tabs will initialize the new aliases.
I think it’s always “dangerous” to write about things like this, because the people who will read this, always have better ideas than the person who wrote it. But I think that’s a good thing for topics like this. So do you have (better) ideas? Leave them here!
Happy coding! :)