I’ve compiled a quick tutorial that explains how to create a new Laravel 5 application and access it on your local computer.
This tutorial assumes that you have a Laravel Homestead virtual machine installed and configured on your computer.
So before you get started, if you haven’t already, set up a Laravel Homestead virtual machine.
Then continue on! :)
Creating a new Laravel 5 web application
With your Homestead virtual machine started, open the command line — Terminal on Mac; Git Bash on Windows — move into your
Homestead folder, and connect to virtual machine:
$ vagrant ssh
Once you’re connected to the virtual machine, move into the folder in which you want to create your application, and then run the following command to create a new Laravel 5 application:
$ composer create-project laravel/laravel <folder-name> 5.1.*
folder-name with the desired folder name for your new application.
That will download and install the Laravel application files and all of its dependencies.
Now you just need to associate a URL with your new application.
Accessing a new Laravel 5 application
There are three steps required:
- To add the new application to the Homestead virtual machine’s configuration
- Add a new entry to the
hostsfile for the app’s URL
- Reload the virtual machine so it recognizes the updated config
Adding a new application to the Homestead configuration
To start, open up the
Homestead.yaml Homestead configuration file in your source code editor; by default, it’s located in your
.homestead directory in your home folder.
(If you don’t see the
.homestead folder, make sure your computer is configured to display hidden files and folders.)
Add a new entry to the
sites section of the configuration file; for example:
. . . sites: - map: <your-app-url> to: /home/vagrant/<your-app-path>/public . . .
<your-app-url> with the URL you wish to associate with your new application and
<your-app-path> with the folder in which your application is located.
Add a new entry to your
In order for your computer to recognize your new Laravel 5 application, you need to add a new entry to your computer’s
hosts file. (For step by step instructions, see the tutorial on editing your computer’s
Add a entry, like so, to the bottom of your
Note: by default,
192.168.10.10 is the IP address associated with a Laravel Homestead virtual machine. If you changed that value, make sure you use your virtual machine’s IP address here instead.
Now you just need to reload your Homestead virtual machine so it recognizes the updated configuration.
Reloading your Homestead virtual machine
Last step: reload the virtual machine so it recognizes your new application and its associated URL.
To start, if you’re still connected to the virtual machine in the command line, run the following command to disconnect:
Then — again, from within your
Homestead directory — run the following command to reload your virtual machine:
$ vagrant reload --provision
Once that’s finished, you should now be able to access your new Laravel 5 application at its designated URL! And if all went well, you’ll see the pleasant Laravel 5 “welcome” page: