Join 25,000+ Laravel Developers and join the free Laravel Newsletter
Laravel Tutorials / updated: August 23, 2017

Laravel Bash Aliases

I don’t use a lot of aliases but I do rely on artisan autocomplete in ZSH. To try and improve my workflow I asked on Twitter if anyone had any useful Laravel bash aliases and had some great responses. Below is a list and I’m sure you will find some goodies:

Chris Fidao

alias ll="ls -lah" # List all, with human readable filesizes
alias c="clear" # Typing the whole word is annoying
alias h="cd ~/" # Go home

alias v='vagrant version && vagrant global-status'
alias vst='vagrant status'
alias vup='vagrant up'
alias vdo='vagrant halt'
alias vssh='vagrant ssh'
alias vkill='vagrant destroy'

This works with git status -sb, and will lint any PHP files that have been modified

alias lint="git status -sb | awk '/s/{print $2}' | sed 1d | xargs -n1 php -l"

Andrew Westrope

alias pa="php artisan"
alias par="php artisan routes"
alias pam="php artisan migrate"
alias pam:r="php artisan migrate:refresh"
alias pam:roll="php artisan migrate:rollback"
alias pam:rs="php artisan migrate:refresh --seed"
alias pda="php artisan dumpautoload"
alias cu="composer update"
alias ci="composer install"
alias cda="composer dump-autoload -o"

Sid

Saves quite a bit of typing

alias art="php artisan"

I added this one as I found myself absent-mindedly typing the whole word now and then

alias artisan = "php artisan"

Handy to add new domains to the host file after mapping on Homestead.yaml

alias edit-host="sudo pico /etc/hosts"

Reset and reseed database

alias db-reset="php artisan migrate:reset && php artisan migrate --seed"

Dwight Watson

I use one alias, and an SSH config.

alias hs="cd ~/Sites/homestead && vagrant up"

To get into the box, I put my SSH config file (~/.ssh/config):

Host homestead
HostName 127.0.0.1
User vagrant
Port 2222

Now, I can type ‘ssh homestead’ to get into the box. Might not be the shortest alias, but I find using the SSH config file makes it easy when you have lots of boxes/servers to get into all the time.

Jeremy Worboys

export PATH="vendor/bin:$PATH"

alias c='clear'
alias l='ls -FlAGh'
alias test="clear && phpunit"
alias art='php artisan'
alias pubkey="/bin/cat ~/.ssh/id_rsa.pub | pbcopy"
alias name="uname -n | tee /dev/ttys001 | pbcopy"
alias vapro="curl -L http://bit.ly/vaprobash > Vagrantfile"
alias chrome="/usr/bin/open -a /Applications/Google Chrome.app"

function convertarrays() {
    curl "https://raw.githubusercontent.com/thomasbachem/php-short-array-syntax-converter/master/convert.php" -o convert.php
    find . -name "*.php" ! -path "*vendor*" -exec php "convert.php" -w "{}" ;
    rm convert.php
}

Yitzchok Willroth

Sorry, couldn’t resist… ;) Hope it made you smile.

alias phart='php artisan';

Do you have any that haven’t been mentioned? Share in the comments.

This appeared first on Laravel News
Laravel News Partners

Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.