Vagrant, Homestead, Laravel and PhpStorm


Prepare Windows 64-bit system to work with Laravel app on a virtual machine with PhpStorm

Download Vagrant and install

https://www.vagrantup.com/downloads.html

Search for cmd (command prompt), run as administrator and type:

vagrant box add laravel/homestead

Navigate to home directory and run:

git clone https://github.com/laravel/homestead.git Homestead

Navigate to Homestead directory and run command from bellow to create the Homestead.yaml configuration file. The Homestead.yaml file will be placed in the ~/.homestead hidden directory:

bash init.sh

After that you will have access to .homestead hidden folder in home directory. Enter and open Homestead.yaml file. Inside that file you will have folders property that you need to modifi. map: is folder on your local machine where you work on your code. sites: property is virtual machine space. Example bellow:

folders: - map: E:\php_storm\laravel\HOMESTEAD\test to: /home/vagrant/Code sites: - map: homestead.app to: /home/vagrant/Code/test/public

After that navigate in terminal again to your Homestead directory and run:

vagrant up

At some point you will be asked for permission to install virtual box:

Say yes to all Windows prompts

Inside PhpStorm you have to go to settings and find Vagrant. You must provide path to vagrant executable file:

C:\HashiCorp\Vagrant\bin\vagrant.exe

Inside your project root instalation bring up terminal and type:

composer require laravel/homestead --dev

Then type:

vendor\bin\homestead make

Inside C:\Windows type N to find notepad. Right click and run as administrator. From notepad File\Open navigate to C:\Windows\System32\drivers\etc. Open your hosts file(remember to check that allFiles are checked not only txt.) and enter:

192.168.10.10 homestead.app

From PhpStorm navigate to tools/vagrant and press:

vagrant up