Setting up our environment for a an enterprise app development with : LARAVEL

Shamsul Alam Jewel
3 min readSep 22, 2019

--

As we will develop our web application with PHP and more specifically with Laravel framework, so we will need to setup PHP, MySQL, npm, nodeJs etc. As I posted on the previous article that every PHP developers should use Homestead for their application development, so we will also going to setup Homestead :)

I would always suggest you to follow the official documentation as often it is updating and the setup guide maybe changed on the newer version. So just open the Homestead installation documentation and follow the official guide.

Here is the official website link: https://laravel.com/docs/6.0/homestead

My development machine is a MACBOOK pro, I would also suggest it as it’s make the life easier of the PHP developer than a Windows machine.

I have also installed homestead in my Windows machine. It also worked. There was one issue I had faced that I have mentioned at the bottom.

Install in Macbook

  1. Install VirtualBox or VMWare, I have installed VirtualBox, check the official site, it also should be mentioned in the homestead official site.
  2. Install vagrant
  3. Once the VirtualBox / VMware and Vagrant have been installed add the laravel/homestead box to your Vagrant installation.
vagrant box add laravel/homestead

4. Install Homestead, clone it to your user directory use this command

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

5. get into the Homestead folder cd ~/Homestead and run bash init.sh this will create a Homestead.yaml file. This is your configuration file.

6. Which vagrant provider should be used? I used virtualbox so check the homestead.yaml file there should be provider: virtualbox

7. Now we have to configure the shared folder. This means which folder will be shared between our Host machine (My Macbook IOS) and the Virtual machine (Ubuntu Linux / Homestead), I usually create a code folder into my user directory and share that folder, so all my projects / applications are inside this ~/code folder. But if you will work with a lot of projects you should map the individual projects map with different folders, this will not make the performance issue. so if you working on a project name project1 then you should map this like

folders:
- map: ~/code/project1
to: /home/vagrant/project1

So for multiple projects the folder mapping will be like this

folders:
- map: ~/code/project1
to: /home/vagrant/project1

- map: ~/code/project2
to: /home/vagrant/project2

If you later see any performance issue also consider adding type: “nfs”

folders:
- map: ~/code/project1
to: /home/vagrant/project1
type: "nfs"

8. Now we have to configure the Sites

sites:
- map: project1.test
to: /home/vagrant/project1/public

Now we are all done, we just need to run the homestead. For UP and Destroy the virtual machine you should use vagrant up and vagrant destroy. So now try vagrant up and see if your website is open in the browser. Also later on you may always need to run vagrant reload — provision for rebooting the server.

9. Before you can see the website on the browser you need to add the sites to the hosts file, in MAC you just need to add the sites on the /etc/hosts file

nano sudo /etc/hosts

192.168.10.10  project1.test

192.186.10.10 is the virtual machine IP address.

So now check http://project1.test

I would suggest to use https:// but for that you can use google chrome and add the certificate into the keychain (MAC) and trust it. so now you can use https://project1.test

Congratulations, now you successfully setup your environment. So you can now start to concentrate for development, The whole installation process should only take 10–15 minutes.

To login to the server you can write

´vagrant ssh´

Issues:

  1. While installing in windows I faced this problem

Not in a hypervisor partition (HVP=0)(VERR_NEM_NOT_AVAILABLE).
VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED).

I was in a Lenovo laptop, so i had to login to bios with F2 and in the Configuration tab, look for the “Intel Virtual Technology” option. It was disabled, I just enable it and restart the PC. That fix the issue.

--

--