Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Laravel 4 Basics Getting Started with Laravel Installing Laravel Homestead

Homestead.yaml File

The Contents of my homestead file are different, someone confirm I am dealing with the correct file:

!/usr/bin/env php

<?php

$_ENV['HOME'] = getenv('HOME'); $_ENV['VAGRANT_DOTFILE_PATH'] = homestead_path().DIRECTORY_SEPARATOR.'.vagrant';

if (file_exists(DIR.'/vendor/autoload.php')) { require DIR.'/vendor/autoload.php'; } else { require DIR.'/../../autoload.php'; }

function homestead_path() { if (isset($_SERVER['HOME'])) { return $_SERVER['HOME'].'/.homestead'; } else { return $_SERVER['HOMEDRIVE'].$_SERVER['HOMEPATH'].DIRECTORY_SEPARATOR.'.homestead'; } }

$app = new Symfony\Component\Console\Application('Laravel Homestead', '2.0.9');

$app->add(new Laravel\Homestead\DestroyCommand); $app->add(new Laravel\Homestead\EditCommand); $app->add(new Laravel\Homestead\HaltCommand); $app->add(new Laravel\Homestead\InitCommand); $app->add(new Laravel\Homestead\ProvisionCommand); $app->add(new Laravel\Homestead\ResumeCommand); $app->add(new Laravel\Homestead\RunCommand); $app->add(new Laravel\Homestead\UpCommand); $app->add(new Laravel\Homestead\UpdateCommand); $app->add(new Laravel\Homestead\SshCommand); $app->add(new Laravel\Homestead\StatusCommand); $app->add(new Laravel\Homestead\SuspendCommand);

$app->run();

8 Answers

Matthew Bingham
Matthew Bingham
11,927 Points

I had a similar issue but managed to resolved it. Here's what I did - hopefully it's useful for anyone looking at this in the future!

It appears that the Homestead.yaml file is now relocated in the src/stubs folder. Edit the content as per the video in this file.

Issues with Windows

If you receive errors such as:

C:/lavarel/Homestead/Vagrantfile:17:in `read': No such file or directory - C:/cygwin64/home/Bieler/.homestead/Homestead.yaml (Errno::ENOENT)
        from C:/lavarel/Homestead/Vagrantfile:17:in `block in <top (required)>'

In sublime (or you text editor), the following files should look like this.

Vagrantfile

Browse to the root of Homestead and open Vagrantfile. Change to the following code:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"

homesteadYamlPath = File.expand_path("~/Homestead/src/stubs/Homestead.yaml")
afterScriptPath = File.expand_path("~/.homestead/after.sh")
aliasesPath = File.expand_path("~/.homestead/aliases")

require_relative 'scripts/homestead.rb'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

Homestead.yaml

Note that this is now in the src/stubs folder (as opposed to the root as shown in the video).

---
ip: "10.0.10.0"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Projects
      to: /home/vagrant/Sites

sites:
    - map: laravel.dev
      to: /home/vagrant/Code/laravel-basics/public

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

# blackfire:
#     - id: foo
#       token: bar
#       client-id: foo
#       client-token: bar

# ports:
#     - send: 93000
#       to: 9300
#     - send: 7777
#       to: 777
#       protocol: udp

Hope that helps someone!

My question was how did I end up with that one even after following all the procedures. Can I just replace the current contents with the correct ones.

Shawn Cho
Shawn Cho
8,307 Points

Apparently you're supposed to run the init.sh that you get within your Homestead directory, type: $ bash init.sh (without the $) The directory will be listed as ".homestead" in your home directory, and the .yaml file will be in there. configure the setup with the homestead.yaml in this directory

Matthew Bingham
Matthew Bingham
11,927 Points

No problem David Metzler - marking up an answer is all the thanks I need ;)

this is how it should look

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

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

can you tell me where is that /home/vagrant/Code path, cause I can't find it anywhere... ?

Thanx Shawn.

It worked, at least to get me past that step. Now when I try to run the 'vagrant up', I get this:

C:\Users\myUserName\Homestead>vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'laravel/homestead' is up to date... ==> default: Clearing any previously set network interfaces... There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "create"]

Stderr: 0%... Progress state: E_FAIL VBoxManage.exe: error: Failed to create the host-only adapter VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended in fo not available) VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,in t,int *)" at line 66 of file VBoxManageHostonly.cpp

Good man, Shawn.

Should I move the contents of the .homestead file into Homestead, or should I just leave them separate? Seems like poor organization to keep them apart, but maybe there's some reason to do so...

@Eric... You should keep it where it is. i.e. in the .homestead folder

David Metzler
David Metzler
16,591 Points

Matthew,

Thanks for the post! Worked for me!

Best,

Dave