In this section, we will download Laravel and set up our local site to use for the rest of our recipes taking advantage of Homestead.
Type the following in the terminal:
>cd ~/Code
Then, download Laravel to a new folder:
>composer create-project --prefer-dist laravel/laravel recipes
Move into the directory for your new application:
>cd recipes
Now we need to tell Homestead about our new application:
>cd ~/.homestead && subl Homestead.yml
Once the editor pops open, you can add your new site:
Under database:
Then, start up Homestead or just provision it:
>homestead provision
You may be asked for a password, which is your system admin password and not the Homestead password.
Then, we need to edit our system Host file (in this case, our local computer and not Vagrant and Homestead); this will again ask for our system password:
>sudo subl /etc/hosts
Next, edit the host file to set your
recipes.dev
domain right next to the default Homestead IP of192.168.10.10
; then, save and close the editor:Then, visit your site at https://recipes.dev! You may get an SSL warning but click on Advanced and Proceed:
The composer command that we ran gets Laravel from its database of applications and libraries at https://packagist.org/ then download it. We began by installing Homebrew to make installing packages easier. We will periodically need to install packages such as Wget
, Webdriver
, and more as we progress through this book. Using the brew
command supplied by Homebrew makes installing these packages a snap.
I also used some shortcuts. One shortcut was subl
, which was what you get when you install http://www.sublimetext.com/. But you can use whatever editor you want.
Using some of the preceding tips will make a shortcut called hedit
adding to my ~/.bash_profile
:
alias homesteadedit='cd ~/.homestead && subl Homestead.yml'
So, we are editing the main file that Laravel uses for all its Homestead settings. You will be here a lot, so shortcuts really pay off.
The same is applicable with the hostedit
command that I used:
alias hostedit='sudo subl /etc/hosts'
Here, we are adding to our .bash_profile
a quick way to edit the file and add the needed domain recipes.dev
and save and exit. Now, when you visit https://recipes.dev, your operating system will know that it is really for Homestead.
Laravel Docs for Homestead: https://laravel.com/docs/5.2/homestead
Some tips there on Windows and the host file: http://sherriflemings.blogspot.ca/2015/03/laravel-homestead-on-windows-8.html
Laracasts (overall a great place for getting started): https://laracasts.com/lessons/say-hello-to-laravel-homestead-two