Setting Up


Setting Up Your Computer

Homestead

Turning on Homestead

cd ~/Homestead
vagrant up

Configuring Homestead

cd ~/.homestead
gedit Homestead.yaml

Configuring Shared Folders

Read more about Homestead here

  1. Scroll down to the folders property in your Homestead.yaml file.
  2. For example:
    The main folder where you put your projects into is a folder named Projects.
    • The folder is located at ~/Documents/Projects on your computer.
    • You want to set up a folder named Projects in root of the Vagrant box to contain your project folders.
      This is how you would configure your Vagrant box inside your Homestead.yaml file:
  folders:
    - map: ~/Documents/Projects //This is the Projects folder location on your computer
      to: /home/vagrant/Projects //This is the Projects folder location inside Vagrant.

Configuring sites

Note

The location of your Vagrant folder may vary based on what you set up in the Configuring Shared Folders step. In our example above, we mapped the Vagrant folder to /home/vagrant/Projects, so our site mapping is pointed towards a folder in that location, therefore /home/vagrant/Projects/myproject

  1. Scroll down to the sites property in your Homestead.yaml file
  2. For example, if you want to map your project, named “My Project” to a domain called myproject.test, which is in the /myproject folder in your shared folder, this is how you would configure it in your Homestead.yaml file:
sites:
  - map: myproject.test //The domain you'll use to access your "served" site locally
    to: /home/vagrant/Projects/myproject //The location of your project's folder in your Vagrant box

Remember to edit your hosts file

Configuring databases

Depending on what you initially named your database during project setup, this is how you can add your database to Homestead:

  1. In your Homestead.yaml file, navigate to the databases property:
databases:
    - myproject

Editing the hosts file

  1. Navigate to and open your hosts file
    bash cd /etc gedit hosts
  2. Add the domain you configured to the end of the file, like this:
    192.168.10.10 myproject.test

Reprovision Homestead

Important

Make sure Homestead is already running before you reprovision Homestead.

Do this every time you edit your Homestead.yaml file.

cd ~/Homestead
vagrant reload --provision

Connecting to Homestead via SSH

Make sure Homestead is running

cd ~/Homestead
vagrant ssh

Setting Up A New Project

Laravel

Before starting your project

  1. Copy .env.example and rename it to .env
  2. Edit the contents of the .env file:
    • APP_KEY
    • DB_DATABASE

Set Up Laravel (Optional)

  1. SSH into Homestead
  2. cd into project directory
  3. Run command: bash laravel new [sitename]

Database

Create Database

cPanel

Assign user to database

Generate Key (for .env file)

  1. Run command
php artisan key:generate
  1. Copy the generated key into the .env file.

Project Dependencies

Install project dependencies

composer install