Pavel Zaněk PavelZanek.com
Select language
Account

New Laravel application - Homestead, Win10

Detailed instructions for installing and configuring a new Laravel application in a local Windows 10 environment, including setting up Homestead, the hosts file and using the Laravel installer.

Published at 2021-12-05 by Pavel Zaněk

Estimated Reading Time: 4 minutes

New Laravel application - Homestead, Win10

Table of Contents

In today's article, I will focus on creating/installing a new Laravel application in a local environment.

Prerequisites

In Brief

Before we look step by step at how to install a new Laravel application in Windows 10 using Homestead and the installer, let's create a small roadmap:

  1. Set up the hosts file
  2. Configure Homestead
  3. Start a new installation using the installer
  4. Launch Homestead with the new configuration

Setting Up the Hosts File

There are several ways to edit files, from using the command line to using something as simple as Notepad. We don't need to play professionals, so Notepad will suffice (wink wink).

So, we open Notepad with the "Run as administrator" option.

Notes Block - run as administrator

In Notepad, we choose File->Open… (CTRL+O) and go to the folder "C:\Windows\System32\drivers\etc". Remember to display all files if you only see .txt files (or see nothing, like me 🙂):

System32 - Drivers - Etc Folder

We see all the files in the folder and open the "hosts" file.

File Hosts in Windows

Now we add:

...
192.168.10.10 your-laravel-application.test
...

Thus, we have mapped the IP address of our future Homestead to a URL. If we enter the URL into the browser later, the requests will be directed to Homestead – let's set it up.

Setting Up the Homestead.yaml File

Go to the folder where you have Homestead installed (in my case "C:\Users\***\Homestead") and open (again you can in Notepad without the need to run the file as an administrator, or in your favorite IDE) the Homestead.yaml file.

Take a look at an example of what your Homestead.yaml could look like.

---
ip: "192.168.10.10"
memory: 512
cpus: 1
provider: virtualbox
ssl: true

authorize: c:/Users/***/.ssh/your-public-key.pub

keys:
    - c:/Users/***/.ssh/your-private-key.ppk

folders:
    - map: d:/laravel-websites
      to: /home/vagrant/code

sites:
    - map: your-laravel-app.test
      to: /home/vagrant/code/your-laravel-app.test/public
      php: '8.0'

databases:
    - your_db_to_application

features:
    - mysql: false
    - mariadb: true
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

# ports:
#     - send: 50000
#       to: 5000
#     - send: 7777
#       to: 777
#       protocol: udp

Several things are worth noting, let's take a look at them.

  • IP address – the same one we used in the hosts file
  • folders – we need to map where the application is located. In my case, I use the "D:\" drive, in which I have a "laravel-websites" folder. This entire folder gets to Homestead under "/home/vagrant/code".
  • databases – we can directly create a db for our application
  • additionally, I showed how you can access Homestead under SSH.

Installing Laravel Using the Installer

Now we know on which URL we will build the application. We also know that if we enter the URL into the browser, we will get to Homestead thanks to the mapping. Homestead is then configured to download content from the local "D:\laravel-websites" folder and place it in "/home/vagrant/code". However, we also know that we are specifically looking for /home/vagrant/code/your-laravel-app.test/public. So we need to install a Laravel application.

So, we go to "D:\laravel-websites" using the command line and run:

laravel new your-laravel-app.test

After completion, the result should end up something like this:

Laravel Installer - New Laravel Application

Launching Homestead with New Configuration

Now we need to start Homestead including our new configuration. So, go to the location where you have Homestead installed (in my case "C:\Users\***\Homestead") in the command line and run:

vagrant up --provision

Alternatively, if you already have Homestead running, you can use (so you don't have to turn off Homestead via "vagrant halt")

vagrant reload --provision

It's important that the --provision switch is used, which launches Homestead with the new configuration.

TIP

If you want to log into Homestead using SSH, just run from the installed folder with Homestead:

vagrant ssh

Then you can get to your application:

cd code/your-laravel-app.test

In Homestead, in the project folder, you can perform various commands (migrations, generation of assets, installation of packages, etc.).

In Conclusion

Now you just need to add the project to your IDE and edit the .env file. Once you configure it, you can enter the URL of the project in the browser and see the new Laravel application. Then just create something great 😉

Share:
5 / 5
Total votes: 1
You have not rated yet.
Pavel Zaněk

Full-stack developer & SEO consultant

Pavel Zaněk is an experienced full-stack developer with expertise in SEO and programming in Laravel. His skills include website optimization, implementing effective strategies to increase traffic and improve search engine rankings. Pavel is an expert in Laravel and its related technologies, including Livewire, Vue.js, MariaDB, Redis, TailwindCSS/Bootstrap and much more. In addition to his programming skills, he also has a strong background in VPS management, enabling him to handle complex server-side challenges. Pavel is a highly motivated and dedicated professional who is committed to delivering exceptional results. His goal is to help clients achieve success in the online space and achieve their goals with the help of the best web technologies and SEO strategies.

Comments

No comment has been added yet.

Add a comment

Suggested Articles

How to create RSS feed in Laravel framework

Published at 2023-08-10 by Pavel Zaněk

Estimated Reading Time: 10 minutes

laravel

Guide to creating RSS feed in Laravel framework without external packages. From basic principles to advanced techniques. Ideal for developers looking for an efficient and secure solution.

Continue reading

Your experience on this site will be improved by allowing cookies. - Cookies Policy