Homestead Laravel

Homestead Laravel

Introduction

While the prospect of getting a new development machine is often very exciting, I usually dread setting up the development machine. I have to download and install a gazillion tools just to get me started. Switching between machines is usually a nightmare. How can you solve such problems?

In a nutshell, if you are a PHP developer, homestead vagrant is the solution to the above started problem. It is a reproducible, and portable development machine that is easy to configure.

By the end of this tutorial, you would have known what vagrant is, its advantages and the tools that you need to get started. Laravel Homestead gives of all of the products in the image below out of the box.

Laravel Homestead

Topics to be covered

We will cover the following topics in this tutorial

  • What is virtualization?
    • Virtualization Software
  • What is vagrant?
  • What is Laravel Homestead?
    • What apps can you develop in homestead environment
  • Advantages of Laravel Homestead
  • System requirements for Laravel Homestead

What is virtualization?

As the name implies, virtualization of the creation of a simulated object that functions like the actual object. For example, a virtual computer is a simulation of an actual computer and it can be used just like a real computer. We can install the operating system on it and do many other tasks.

There are many advantages to virtualization. Imagine that you are a software developer and needs to see how your system performs in different operating systems. You may want to test the application on Windows, Linux and Mac OS. It could be you want to test the application on Windows only but try different versions i.e. Windows 7, 8, and 10.

Buying dedicated machines for such cases could be very costly for you and even if you manage, who wants to use a lot of different machines at the same time. Virtualization is the solution to the above challenge. All you need is a single machine with great specifications and you can have as many virtual machines as you want.

Virtualization software

Virtualization software enables you to create virtual machines. Some of the virtualization software is free and others are commercial. Let’s look at some of the popular virtualization software.

  • Oracle Virtual Machine – this is developed by Oracle and it is free. You can run it on Windows, Linux or Mac OS.
  • VMWare – this is one of the most popular virtualization software providing a wide range of products. It is cross platform and it’s a commercial product.
  • ...and many more – Wikipedia has a list of virtualization software that you can check out too if you are interested.

In these tutorial series, we will be working with Oracle Virtual Machine.

What is vagrant?

In a nutshell, vagrant is a command line utility for managing the lifecycle of virtual machines. Vagrant makes it easy for you to configure and manage reproducible and portable work environments.

The configuration settings for the development environment are stored in a vagrantfile that you can share with other developers. The vagrantfile settings can be configured by a single command vagrant up. The configuration file is cross platform. You don’t need to worry about the operating system that other members are using. Such is the “sinful” nature of vagrant :)

What is Laravel Homestead?

In a nutshell, homestead is a pre-packaged vagrant box that provides you will all the development tools that you need by default.

Let me explain using the roles and permissions analogy. In a role and permissions based authorization system, you define users such as admin and limited. You assign permissions to roles i.e. admin can do everything while limited cannot do certain tasks. When you create a new user, all you do is assign them a role and the permissions defined for that role will automatically be applied to the new user. This saves you the time of assigning the roles individually.

Homestead is similar to a role. It comes with all the PHP and Web development tools required to develop web applications. Once you have setup your virtual machine and vagrant, you simply add homestead box to it and all of the development tools are installed automatically for you. This saves you the time of individually installing the required software.

What apps can you develop in homestead environment

Laravel homestead isn’t a Laravel framework development framework only. Nope, you can generally development any PHP web application using homestead. We will look at how we can do this as we proceed in the tutorial series.

Advantages of Laravel Homestead

We already briefed covered this when we started the advantages of virtualization in the above sections. Let’s now look at some more advantages.

  • Local development environment simulates production environment – most PHP apps are usually hosted on servers that run Linux. I am most a windows environment developer and I almost always run into issues when I publish my apps. Having a development environment that closely mirrors the production allows me to catch issues when developing. This makes publishing apps and updates a blissful thing to do.
  • Comes with almost 99.99% of the required software – if you are running PHP locally and need to take advantage of a cache database such as Redis, you will have to do the installation and configuration yourself. Homestead already has this done for you. In a nutshell, you will get the following out of the box
    • Ubuntu 16.04
    • Git
    • PHP 7.1
    • Nginx
    • MySQL
    • MariaDB
    • Sqlite3
    • Postgres
    • Composer
    • Node (With Yarn, PM2, Bower, Grunt, and Gulp)
    • Redis
    • Memcached
    • Beanstalkd
  • It can be disposable and recreated within minutes (application source code untouched) – when you have development tools on your host system and something goes wrong, formatting the machine and reinstalling can be a pain in quite a significant part of the body. You do not have to worry about that with homestead. You can easily discard the virtual machine and recreate it without affecting your code. This gives you a clean environment to work with.
  • Its sharable – the vagrantfile configuration file that be easily shared with team members to configure exact development environments.
  • It works – it’s one thing to promise something and another to deliver. Laravel homestead has a track record of success. It’s something that you can count on to deliver on its promises.
  • Easily deploy code to your production server – vagrant has a push command that you can use to deploy code to the production server.

System requirements for Laravel Homestead

In this section, we will look at the system requirements for installing Laravel Homestead. You will basically need the following

Hardware

If you are using windows, you will need a processor that supports virtualization. The easiest way of checking if your processor supports virtualization is;

Right click on the task bar

Select Task Manager menu

Go to performance tab

Windows Virtualization Enabled

If virtualization is supported, the state will either be Enabled or Disabled. If it is disabled, you will need to enable it from the BIOS Setup.

Disk Space

You will need to have sufficient storage space. Homestead box image is about 1GB. The virtual machine that I have created is close to 4GB. Based on these factors. I think its safe to have about 20GB of free space.

RAM

A minimum of 4GB is usually sufficient but having 6GBplus of RAM provides a better experience.

Software

VirtualBox

You will need to install virtualization software. For this tutorial, we will be using VirtualBox. We will not include the instructor of how to download and install VirtualBox. The process is just like installing any other software.

Vagrant

You can download Vagrant from the official website https://www.vagrantup.com/downloads.html installing vagrant is like installing any other program. Use the comments section if you have any questions or difficult installing it.

Git

This is especially needed for Windows users. We will be using Git bash to interact with our vagrant box.

When you are done installation all of the above software, you will need to restart your machine.

Summary

In this tutorial, we have looked at what virtualization is and what it can do for us. We got introduced to vagrant and homestead. We also looked at the system requirements needed to get up and running with Laravel Homestead.

What’s next?

The next tutorial will look at how to install and configure homestead.

Kode Blog Tutorials is dedicated to bring you update to date, high quality free tutorials. You can support us by using the social media buttons to like and share the tutorial and subscribing to our newsletter. Please use the comments section below to give us feedback.

You can sign up for a free account on our site and you will be able to keep track of your progress as you go through the tutorial series.

Our Curriculum

This tutorial shows you how to install homestead laravel on a windows machine and configure it...readmore

This tutorial shows you how to create and configure a new laravel project in homestead vagrant box...readmore

Related Tutorials