Homestead per-project crib sheet
I wanted a drop-dead simple way to try and replicate a problem someone was having on the Slim forums. I couldn’t reproduce with php -S which is my go-to for this sort of thing, so I thought I’d try Homestead.
I had recently listend to a Voices of the Elephpant episode with Taylor Otwell & Joe Ferguson where Joe mentioned that Homestead worked on a per-project basis too. I didn’t know this, so tried it out. The docs are fine, but there’s a lot there that covers the global installation option when I just want to get up and running on a per-project basis.This is my crib sheet:
1. Create project
$ composer create-project slim/slim-skeleton skelly
$ cd skelly
We just need a project that uses Composer. You probably have one already. If not, Slim Framework is a good choice!
2. Add Homestead to the project
$ composer require laravel/homestead --dev
$ php vendor/bin/homestead make
The make command creates VagrantFile and a Homestead.yaml for configuration.
3. Deal with IP address and hostname
By default, the Homestead vagrant box is set up on 192.168.10.10 with the hostname homestead.app. You can change this in Homestead.yaml.
Add the IP address to /etc/hosts. This only needs to be done once if you don’t change the defaults.
$ echo "192.168.10.10 homestead.app" | sudo tee -a /etc/hosts
All done
We’re all done, so we can use vagrant up to run our new website Go to homestead.app in a browser to see it. To shut down, use vagrant halt or vagrant destroy.
You can also use Homestead Improved which is set up for this from the get-go: http://www.sitepoint.com/quick-tip-get-homestead-vagrant-vm-running/
Hi Bruno, Homestead Improved needs to be updated. I reached out via twitter but saw no response: https://twitter.com/JoePFerguson/status/811731377305649152 Regarding https://github.com/laravel/homestead/issues/405
Cheers
Thanks for writing about this Rob, I'm really proud of this feature of Homestead and think it's awesome to be able to add a vagrant environment to a project in only a few commands.