Laravel Bash Aliases

Published on by

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.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Forge
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
All Green logo

All Green

All Green is a SaaS test runner that can execute your whole Laravel test suite in mere seconds so that you don't get blocked – you get feedback almost instantly and you can deploy to production very quickly.

All Green
Larafast: Laravel SaaS Starter Kit logo

Larafast: Laravel SaaS Starter Kit

Larafast is a Laravel SaaS Starter Kit with ready-to-go features for Payments, Auth, Admin, Blog, SEO, and beautiful themes. Available with VILT and TALL stacks.

Larafast: Laravel SaaS Starter Kit
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector

The latest

View all →
Property Hooks Get Closer to Becoming a Reality in PHP 8.4 image

Property Hooks Get Closer to Becoming a Reality in PHP 8.4

Read article
Asserting Exceptions in Laravel Tests image

Asserting Exceptions in Laravel Tests

Read article
Reversible Form Prompts and a New Exceptions Facade in Laravel 11.4 image

Reversible Form Prompts and a New Exceptions Facade in Laravel 11.4

Read article
Basset is an alternative way to load CSS & JS assets image

Basset is an alternative way to load CSS & JS assets

Read article
Integrate Laravel with Stripe Connect Using This Package image

Integrate Laravel with Stripe Connect Using This Package

Read article
The Random package generates cryptographically secure random values image

The Random package generates cryptographically secure random values

Read article