It’s a lovely day tomorrow: Installing Vagrant, Virtualbox, Homestead and Laravel, and integrating it with PhpStorm

The above is something I have been struggling with over the last couple of days. I have sent a bug report to JetBrains the author of PhpStorm regarding this and have I posted a query to Stack Overflow. In the meantime I am looking at yet another tutorial for installing Vagrant, Virtualbox, Homestead and Laravel. This time with the assistance of the Youtube channel Code Course a channel I have found to be helpful in learning to code better.

Anyway this note to myself, something to slow me down and something which may be useful to others to see how I have attempted to resolve what for me at the moment is a dead end.

At this point I have installed Vagrant, Virtualbox, Homestead and a base version of the Laravel website which I can view on my host machine. All good. However when I attempt to create a project based on the synced code PhpStorm crashes magnificently.

So what next? I will listen to the pleasant English tones of the chap at Code Course and let him explain to me how he goes about the task as seen in the title. Making brief notes re stuff I need to remember or which I didn’t previously know.

Video 1 Laravel / Homestead guide

  • Virtualbox is a hypervisor : software that allows you to create virtual machines on your host machine
  • Vagrant is a helper which assists Virtualbox to easily
  • Larvel/Homstead is a predefined environment which is recommended for Laravel

Video 2 Laravel / Homestead guide

  • Once Vagrant and Virtualbox are installed run the following command to add the Laravel/Homestead box

vagrant box add laravel/homestead

  • Next we need to clone the Homestead repository to manage websites change settings and to start up the Homestead server etc. For this we create a directory and run the following command from within this directory.

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

  • On Ubuntu I now run

bash init.sh

  • The above command generates amongst other files the configuration file for Homestead: Homestead.yaml . This file has entries for configuring ssh, shared folders and nginx’s domain entry. Info on how to do this is here. Remember to add a related domain entry in the /etc/hosts
  • Once the required changes have been made to the yaml file we then bring up the Homestead machine by running the below from within the Homestead directory.

vagrant up

  • If all goes well we should now have a working machine which we can ssh to.
  • Looking back at the output of the command we can see the ports that the Homestead ports have been forwarded to.
    • http 80 -> 8000
    • https 443 -> 44300
    • MySQL 3306 -> 33060
    • ssh 22 -> 2222

Video 3 Laravel / Homestead guide

  • Homestead is now up and running and we can now ssh into our Homestead box. We do this from within the Homstead directory on our host machine.

vagrant ssh

  • We now need to install Laravel globally on our virtual machine. This is done within our main code directory

composer global require laravel/installer

  • And now create a new Laravel site

laravel new <sitename>

Later that day ……..

  • The site was created and could be seen on the host on the domain as entered in /etc/hosts and on port 8000
  • Now for the big kerfuffle could I create a PhpStorm project using the synced content as my project soure …….. NO WAY . The thing fell over as it did previously whilst indexing.
  • What next ah what has just turned up in my email box and email from JetBrains ….. this is a know issue ARGGHHHHHHHHH. Or to quote

As for the crash – that’s a known issue, our developers are looking into it: https://youtrack.jetbrains.com/issue/JBR-1223. You can vote for or comment it in order to get notified about its updates.
The crash happens inside Java 11 virtual machine. As a workaround we can suggest running IDE on Java 8. Here’s a link to latest PhpStorm version with Java 8 bundled: https://download.jetbrains.com/webide/PhpStorm-2019.3.2-jbr8.tar.gz – please unpack it into an empty directory.

I think all of this is an illustration of how things work – it is a lovely day tomorrow to quote a cheesey Broadway song. Not sure about today ; )

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s