Click to share! ⬇️

Building A Forum With Laracasts

We’re going to get back to working with Laravel now. We had a break for a minute exploring some WordPress topics and other such adventures, and now we are refreshed and ready to get back to some test driven development using the very latest and greatest versions of Laravel, Vue, and more. Laracasts.com has a fantastic series of building a forum using Laravel. We will attempt to follow along and see if we can get this working on our own machine. I have a feeling it is going to be pretty intense, but I have faith! Let’s dig in now.


Setting Up Our New Project

There is nothing better than the blank slate. Starting fresh with no bloat, no bugs, and nothing to fix. Just the clear blue sky ahead, and a chance to build some cool stuff. This is probably my favorite point in a project. We’re using homestead, so let’s go ahead and set up the beginnings of our new project, forum.io.


We can add this snippet to our Homestead.yaml file to begin:

sites:
    - map: forum.io
    - to: /home/vagrant/Code/forumio

Since we are not using the very cool Laravel Valet, we’ll still need to edit our hosts file. No biggie, here we go:

#homestead
192.168.10.10   forum.io

Finally, let’s grab a fresh copy of the latest version of Laravel.

composer create-project laravel/laravel forumio --prefer-dist

We are ready to bring this project to life!
vagrant up forumio

Ah ha, we have a message:

$ vagrant up
Bringing machine 'homestead-7' up with 'vmware_workstation' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: A newer version of the box 'laravel/homestead' is available! You currently
==> homestead-7: have version '4.0.0'. The latest is version '5.0.1'. Run
==> homestead-7: `vagrant box update` to update.

We are to use the latest tools. We must update this system. We can do so using the vagrant box update command.

$ vagrant box update
==> homestead-7: Checking for updates to 'laravel/homestead'
    homestead-7: Latest installed version: 4.0.0
    homestead-7: Version constraints: >= 2.0.0
    homestead-7: Provider: vmware_desktop
==> homestead-7: Updating 'laravel/homestead' with provider 'vmware_desktop' from version
==> homestead-7: '4.0.0' to '5.0.1'...
==> homestead-7: Loading metadata for box 'https://atlas.hashicorp.com/laravel/homestead'
==> homestead-7: Adding box 'laravel/homestead' (v5.0.1) for provider: vmware_desktop
    homestead-7: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/5.0.1/provid       ers/vmware_desktop.box
    homestead-7:
==> homestead-7: Successfully added box 'laravel/homestead' (v5.0.1) for 'vmware_desktop'!

Ok, one more time!

$ vagrant up
Bringing machine 'homestead-7' up with 'vmware_workstation' provider...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
==> homestead-7: Verifying vmnet devices are healthy...
==> homestead-7: Preparing network adapters...
==> homestead-7: Starting the VMware VM...
==> homestead-7: Waiting for machine to boot. This may take a few minutes...
    homestead-7: SSH address: 192.168.217.128:22
    homestead-7: SSH username: vagrant
    homestead-7: SSH auth method: private key
==> homestead-7: Machine booted and ready!
==> homestead-7: Forwarding ports...
    homestead-7: -- 80 => 8000
    homestead-7: -- 443 => 44300
    homestead-7: -- 3306 => 33060
    homestead-7: -- 5432 => 54320
    homestead-7: -- 8025 => 8025
    homestead-7: -- 27017 => 27017
    homestead-7: -- 22 => 2222
==> homestead-7: Setting hostname...
==> homestead-7: Configuring network adapters within the VM...
==> homestead-7: Waiting for HGFS to become available...
==> homestead-7: Enabling and configuring shared folders...
    homestead-7: -- C:/homestead: /vagrant
    homestead-7: -- C:/localdev: /home/vagrant/Code
==> homestead-7: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> homestead-7: flag to force provisioning. Provisioners marked to run always will still run.

This is fantastic, let us now go ahead and load up our new site in the browser at forum.io. Hmmm, ok this is not what we intended. I must have made a mistake somewhere, maybe it is the .io domain. Let’s try changing it over to .dev and see if this helps.

Sorry, the page you are looking for could not be found.
(1/1) NotFoundHttpException
in RouteCollection.php (line 179)
at RouteCollection->match(object(Request))
in Router.php (line 548)
at Router->findRoute(object(Request))
in Router.php (line 527)
at Router->dispatchToRoute(object(Request))
in Router.php (line 513)
at Router->dispatch(object(Request))
in Kernel.php (line 174)
at Kernel->IlluminateFoundationHttp{closure}(object(Request))
in Pipeline.php (line 30)
at Pipeline->IlluminateRouting{closure}(object(Request))
in TransformsRequest.php (line 30)
at TransformsRequest->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->IlluminatePipeline{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->IlluminateRouting{closure}(object(Request))
in TransformsRequest.php (line 30)
at TransformsRequest->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->IlluminatePipeline{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->IlluminateRouting{closure}(object(Request))
in ValidatePostSize.php (line 27)
at ValidatePostSize->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->IlluminatePipeline{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->IlluminateRouting{closure}(object(Request))
in CheckForMaintenanceMode.php (line 46)
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->IlluminatePipeline{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->IlluminateRouting{closure}(object(Request))
in Pipeline.php (line 102)
at Pipeline->then(object(Closure))
in Kernel.php (line 149)
at Kernel->sendRequestThroughRouter(object(Request))
in Kernel.php (line 116)
at Kernel->handle(object(Request))
in index.php (line 53)

Ok changing over to forum.dev in the Homestead.yaml file and hosts file with a vagrant provision to rebuild everything did not help. We now have a 403 Forbidden nginx/1.11.9 error. Interesting. Ah ha, I am dumb. It looks like I made a mistake in in the Homestead.yaml file and forgot to include the /public in the sites section like so:

sites:
    - map: forum.io
      to: /home/vagrant/Code/forumio/public

We are now going back to forum.io across the board and running vagrant provision one more time. Fingers crossed, and yes we now have a beautiful fresh installation of Laravel that is ready for our hacking.
ready to build a forum

We can also open up the project in PHP Storm and get ready to go to work.
ready to hack in phpstorm


Summary Of Getting Ready To Build A Forum

Well, after having taken a break from working with Laravel for a quick minute, we can see that my skills were a bit rusty in setting up a new project using Laravel, Homestead, VMWare Desktop, and Vagrant. Have no fear however! We are now ready to begin, and in the next many tutorials, we will follow along with Jeff at Laracasts to build a forum from scratch using Test Driven Development. We are bound to encounter many errors along that way, which is fantastic. Errors are the fertilizer of learning new things.

Click to share! ⬇️