Skip to content
Muhammet Şafak
tr
Tools & Technologies 3 min read

Consistent Development Environments for Everyone with Laravel Homestead

A step-by-step walkthrough of setting up Laravel Homestead to eliminate the classic 'it works on my machine' problem across teams.


“It works on my machine — why doesn’t it work on yours?” Every developer has either said this or heard it at least once. One person is running PHP 5.4, another is on 5.6; one has MySQL 5.5, another has 5.7. As local environments diverge, these kinds of problems become unavoidable.

Laravel Homestead is a pre-packaged Vagrant box designed to solve exactly this problem on the development side. Vagrant sits on top of virtualization tools like VirtualBox or VMware, and with a single configuration file it provides an identical development environment for the entire team.

In this post I’ll walk through how I set up Homestead from scratch and configured it to work with multiple projects.

Prerequisites

You need two tools to run Homestead:

  • VirtualBox — free, download from virtualbox.org
  • Vagrant — the virtual machine manager, download from vagrantup.com

Both work regardless of operating system — Windows, macOS, Linux, it doesn’t matter. That’s kind of the whole point.

After installing both:

vagrant plugin install vagrant-vbguest
vagrant box add laravel/homestead

The vagrant box add command downloads the Homestead box — it can take a few minutes since the box is roughly 1 GB.

Installing Homestead

There are two ways to install Homestead globally on your system: via Composer, or by cloning the Git repository directly. The Composer approach is more practical:

composer global require "laravel/homestead=~2.0"
homestead init

This creates a ~/.homestead/Homestead.yaml file in your home directory. All configuration is managed from there.

Configuring Homestead.yaml

The configuration file has the following sections:

ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

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

sites:
    - map: project.app
      to: /home/vagrant/Projects/project/public

databases:
    - project_db

A few important points:

  • folders: You’re mapping a directory on your local machine to the virtual machine. Your ~/Projects folder appears as /home/vagrant/Projects inside the VM.
  • sites: You assign a domain name to each project. project.app will be accessible from your local machine.
  • databases: Any databases you name here are created automatically.

After saving the configuration, you need to add the domain to your /etc/hosts file:

192.168.10.10  project.app

Starting the Virtual Machine

homestead up

The first time you run this, the box is provisioned. Subsequent starts take just a few seconds. Navigate to http://project.app in your browser and your project loads right up.

homestead ssh

This command connects you to the virtual machine. You run Artisan commands, database operations, and everything else from inside here.

What Does Homestead Include?

The Homestead box comes pre-configured with: PHP 5.6 (with 5.5 and 7.0 beta options available), Nginx, MySQL, Postgres, Redis, Memcached, Beanstalkd, Node.js, and Composer. You don’t need to install any of these separately.

Running Multiple Projects

It’s entirely possible to run multiple projects from the same Homestead installation. You add new entries to the sites and databases sections, add the new domain to /etc/hosts, and apply the updated configuration with homestead reload --provision.

sites:
    - map: project-a.app
      to: /home/vagrant/Projects/project-a/public
    - map: project-b.app
      to: /home/vagrant/Projects/project-b/public

Each project runs on its own domain, all inside a single virtual machine.

Initial Impressions

I used Homestead on my own for a few days before introducing it to the team. The biggest advantage is that it completely eliminates version mismatch headaches on local machines. You stop thinking about which PHP version you have installed and just start writing code.

The downside is the VM’s resource consumption. On a machine with limited RAM, you can notice a real slowdown. In practice though, this wasn’t much of an issue beyond the initial setup phase.

Homestead genuinely solves the “environment setup” headache, especially in small teams. When a new developer joins a project, they’re up and running in minutes, not hours.

Tags: #Laravel
Share:

Comments

Sign in with your GitHub account to join the discussion. Comments are stored in GitHub Discussions.

Related Posts

Search the site

Start typing to search posts, projects and pages.

Esc to close Powered by Pagefind