Skip to content

Instantly share code, notes, and snippets.

@webkenny
Last active December 20, 2018 04:41
Show Gist options
  • Save webkenny/f66beda1630fa08a646a to your computer and use it in GitHub Desktop.
Save webkenny/f66beda1630fa08a646a to your computer and use it in GitHub Desktop.
Run artisan command inside a Homestead VM from the local shell
#######################################
# Run artisan on the Homestead VM
#
# Arguments:
# Folder
# Command to Run
# Returns:
# Output of the Artisan Command
#######################################
function artisan() {
ssh homestead cd /home/vagrant/Code/$1 && php artisan $2
}

The .bashrc example allows you to run an artisan command from your local terminal inside a Homestead VM.

  1. SSH to the VM
  2. Change into the directory where your site lives
  3. Run an artisan command.

I named my function "artisan" so it overrides the default but you can name it whatever you like. This also assumes you have setup an alias in your ~/.ssh/config file but that isn't strictly necessary. This will also work simply passing in the username and IP. e.g. ssh [email protected]

Change your path if you are using something other than the default of /home/vagrant/Code.

Example usage if I want to run a list command inside the site called myapp:

artisan myapp list

Hope this helps someone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment