Laravel Homestead
My quick reference for setting up and using Laravel Homestead during development.
#laravel #homestead #vagrant #virtualbox
Laravel Homestead is the virtual machine I use for local Laravel development. It provides a consistent development environment with PHP, Composer, MySQL, Nginx, Redis, and other tools already configured.
Prerequisites
Before installing Homestead, install:
- VirtualBox
- Vagrant
- Git
Install Homestead
Clone the Homestead repository.
git clone https://github.com/laravel/homestead.git ~/Homestead
Move into the directory.
cd ~/Homestead
Initialize Homestead.
bash init.sh
This creates your Homestead.yaml configuration file.
Configure Homestead
The main configuration file is:
~/Homestead/Homestead.yaml
Common settings include:
folders:
- map: C:\Codes
to: /home/vagrant/Codes
sites:
- map: my-app.test
to: /home/vagrant/Codes/my-app/public
databases:
- my_app
Start the Virtual Machine
vagrant up
Or using my Bash alias:
hm-start
SSH into Homestead
vagrant ssh
Or:
hm-ssh
Stop Homestead
vagrant halt
Or:
hm-stop
Reload Homestead
After changing Homestead.yaml:
vagrant reload --provision
Or:
hm-reload
Laravel Commands
Once inside the VM:
php artisan serve
php artisan migrate
composer install
php artisan optimize:clear
Access phpMyAdmin
If you have phpMyAdmin installed in Homestead:
http://phpmyadmin.test
or your configured local domain.
Useful Commands
Check VM status.
vagrant status
Suspend the VM.
vagrant suspend
Resume the VM.
vagrant resume
Destroy the VM.
vagrant destroy
Related Notes
/dev/bash/my-bash-rc/dev/bash/git-commands
Eloquent Relationships
The core Eloquent relationship types with examples and the N+1 trap to avoid.
Bash
Shell scripting and a faster life on the command line.