Understanding the Homestead yaml file in Laravel

fs_tigre picture fs_tigre · Mar 19, 2015 · Viewed 10.7k times · Source

Can someone explain the Homestead.yaml file in details. Not fully understanding its contents is bothering me.

Here is the complete Homestead yaml file:

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Code
      to: /home/vagrant/Code

sites:
    - map: homestead.app
      to: /home/vagrant/Code/Laravel/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

And here is what I understand about its content, correct me if I'm wrong and of course add comments.

authorize: ~/.ssh/id_rsa.pub
A directory in your local machine where you store the public .ssh file. This folder can be any folder in your local machine, right?

keys: - ~/.ssh/id_rsa
A directory in your local machine where you store the local .ssh file. This folder can be any folder in your local machine, right?

folders:
- map: ~/Code
to: /home/vagrant/Code

  • -map: A directory in your local machine where you store all of your porjects. This folder can be any folder in your local machine, right?

  • to: I believe this is where your projects will be stored in the virtual machine, if this is correct, does the last folder needs to match the last folder in the local structure?

sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public

  • -map: I believe this is the url or domain you will be using to get to your site and it can be anything you want as long as you add it to your localhost file, correct?

  • to: I'm not sure what this is...

databases:
- homestead
A databese called homestead will be created automatically, correct?

Thanks

Answer

Borjante picture Borjante · Mar 25, 2015

authorize: ~/.ssh/id_rsa.pub A directory in your local machine where you store the public .ssh file. This folder can be any folder in your local machine, right? Yes

keys: - ~/.ssh/id_rsa A directory in your local machine where you store the local .ssh file. This folder can be any folder in your local machine, right? Yes

Homestead.yaml uses lots of defaults, this way when creating a new .ssh key you do not need to touch anything

folders: - map: ~/Code to: /home/vagrant/Code

-map: A directory in your local machine where you store all of your porjects. This folder can be any folder in your local machine, right? Yes to: I believe this is where your projects will be stored in the virtual machine, if this is correct, does the last folder needs to match the last folder in the local structure? No there isno need to, you just specify a route in your virtual machine and it will be filled with all files in the -map: folder

sites: - map: homestead.app to: /home/vagrant/Code/Laravel/public

-map: I believe this is the url or domain you will be using to get to your site and it can be anything you want as long as you add it to your localhost file, correct? to: I'm not sure what this is...

This two lines are configuring something like a virtualhost, i'm not sure how it really works internally, but basically you map one folder (to) to one domain (map), this will create a new virtualhost so that you can access you website by typing: homestead.app in you local machine browser. Remember that you need to edit your hosts file, either /etc/hosts or /windows/system32/drivers/etc/hosts and add a new line something like:

192.168.10.10 homestead.app

databases: - homestead Not sure about this one, i will take a look at it but it seems to me that you are right, just define a new name and omestead will create DB for you.

Hope this helps