Laravel (5.7) Homestead
Laravel can be defined as the exotic PHP experience, which is elegant to manage and provide virtual machines. The Laravel homestead is an official pre-package that provides a variety of development environment without the need of PHP or any other server software. Homestead runs on all kinds of the operating system which includes Mac, Windows or Linux system. The servers supported are Nginx, MySQL, Memcached, Node, PostgreSQL, Redis and several other options that are needed to develop Laravel application by making the user experience a delight. Vagrant provides a simple, elegant way to manage and provision Virtual Machines. With Vagrant, no more worrying about messing up your operating system! Vagrant boxes are completely disposable. Vagrant Box is the supporting software that comes along with Homestead.
- Ubuntu 18.04
- PHP 7.3
- PHP 7.2
- PHP 7.1
- Apache (Optional)
- MariaDB (Optional)
- Node (With Yarn, Bower, Grunt, and Gulp)
- Neo4j (Optional)
- MongoDB (Optional)
- Elasticsearch (Optional)
- Zend Z-Ray
Installation and Setup
Before we go on to launch our Homestead environment, there are necessary tools to have before it can work. These areVirtualBox,VMWare,Parallels orHyper-V as well asVagrant. All of these software packages provide easy-to-use visual installers for all popular operating systems.
To use the VMware provider, you will need to purchase both VMware Fusion / Workstation and theVMware Vagrant plug-in. Though it is not free, VMware can provide faster shared folder performance out of the box.
To use the Parallels provider, you will need to installParallels Vagrant plug-in. It is free of charge.
Because of Vagrant limitations, The Hyper-V provider ignores all networking settings.
Installing Vagrant box
You can easily install this with all other supporting software. A simple command will do the installation for you:
vagrant box add laravel/homestead
If this command fails, make sure your Vagrant installation is up to date.
You could install Homestead by simply cloning a repository.
git clone https://github.com/laravel/homestead.git ~/Homestead
The "Home" directory will save the cloned repository. The Homestead box serves as a host for all your Laravel projects. Once you are done with the repository part you would need to run;
bash init.sh for // Mac / Linux... init.bat for // Windows
These commands aid to configure the software.
Configuring homestead can be done in a few steps;
The provider key found in the Homestead.yaml file indicates that the Vagrant box should be either of VMWare workstation, Hyper-V, VirtualBox or other supporting software previously installed. You can also set your provider to the one you prefer by doing this;
Folders are the property of homestead file system to share with the environment. Depending on the changes in the files, the local machine will be synchronized. In some cases the default shared folder implementations (such as VirtualBox shared folders) have high performance penalties. If you are seeing less than ideal performance with synced folders,NFS can offer a solution. Vagrant has built-in support to orchestrate the configuration of the NFS server on the host and guest for you. To enableNFS, you only need to add a simple flag to your synced folder configuration:
folders:- map: ~/code to: /home/vagrant/code type: "nfs"
The "sites" property allows you to easily map a "domain" to a folder on your Homestead environment. You can add as many sites to the environment as required. Homestead is a convenient virtual space for all your Laravel projects
In this step, you are required to add your domains for all the Nginx sites, to the files that are a host on your machine. The main purpose of doing this is, that the host file redirects the requests for homestead sites into your machine.
On Mac/Linux, these files are located in /etc/hosts by default. On Windows, it is located at C:\Windows\System32\drivers\etc\hosts.
Launching the Vagrant Box
Once you have edited the Homestead.yaml file to your satisfaction, you can then run the vagrant up command from your Homestead directory. Vagrant will boot the virtual machine and automatically configure your shared folders and Nginx sites.
To destroy or quit the machine, you may use the vagrant
destroy --force command.
Pre-installed MySQL can be used to sync your Homestead environment. Once you are done with the Database synchronized, you are all set to host your new project in the Laravel Homestead. There are various additional packages that can be added based on its usage. Some of the most common ones which come with the Homestead package are:
For Mac and Linux users, this is something you need to do for daily global access.
By just adding the Bash function to the Vagrant Box, the scripts allow you to run on any Vagrant command in your system from anywhere and this actually will automatically point the particular command to your Homestead installation folder.
- Exercises: Weekly Top 16 Most Popular Topics
- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools