Add Your Own Aliases to Laravel Homestead

Add Your Own Aliases to Laravel Homestead

Laravel Homestead ships with some aliases that get copied into your Homestead virtual machine when you provision it. These aliases are available inside the virtual machine, and you can also add your aliases as well so that you have the same aliases in Homestead that you might use on your local setup. I’ll quickly show you how you can add your aliases.

After you install Homestead and run bash init.sh, the init script copies the aliases file to ~/Homestead/aliases on OS X.

When you make changes to the aliases file, you need to reprovision the image:

vagrant reload --provision

If you look at the Vagrantfile, you can see how the aliases file gets copied into the Homestead machine. By default, Homestead has some helpful aliases already defined that you can use right away:

alias ..="cd .."
alias ...="cd ../.."

alias h='cd ~'
alias c='clear'
alias art=artisan

alias phpspec='vendor/bin/phpspec'
alias phpunit='vendor/bin/phpunit'
alias serve=serve-laravel

alias xoff='sudo phpdismod -s cli xdebug'
alias xon='sudo phpenmod -s cli xdebug'

For example, you can run “h” to go to the home folder, or run “phpunit” without referencing the full vendor/bin path. Another way I like to achieve something similar is adding vendor/bin to my path:

export $PATH="./vendor/bin:$PATH"

Also, last week we shared some great Laravel community bash aliases that you might consider adding to Homestead!


Filed in: Laravel Tutorials / Homestead


Newsletter

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

Laravel News Partners

Laravel Jobs

Full-Stack Developer
Tampa, FL / Remote
Nu Image Medical
PHP Developer
Remote
X-Team
Full-Stack Developer
Sioux Falls, SD or Remote
Electric Pulp
Senior PHP / Vue.js Developer
Portland, OR / Remote
Bright Oak
Full Stack Vue.js Developer (Front-end focus)
Remote
LenderHomePage.com
Senior Laravel Web Application Developer
NYC or Remote
Happy Cog
Laravel Developer (Vue, SQL Server)
Geneva, Switzerland / Remote
World Trade Organization