Laravel 8 custom domains on Localhost
Laravel 8 custom domains on Localhost
by on on other

Laravel 8 custom domains on Localhost

We all know that laravel 8 is a game changer, one thing I love about PHP is the ability it gives to use custom domains on our localhost using laravel. so here is a step by step guide we are going to be using to achieve that.

Before we proceed do make sure you have composer and xampp installed on your local machine.

Step one: Create a laravel project, the preferred path to create is the path of your xampp/htdocs folder. here is how mine looks like. 

C:\xampp\htdocs\laravelapi

Step two: This step comprises of modifying two files, one of it is found on our xampp folder and the other one is found in hots folder in our system. Now let's edit these files perfectly.

C:\xampp\apache\conf\extra\httpd-vhosts.conf

The file above allow us to point to our project folder and create a custom domain. here is an example of how that will look like.

<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\laravelapi\public"
    ServerName laravelamazon.com
</VirtualHost>

The second file is located inside of your windows system32 folder path.

C:\Windows\System32\drivers\etc\hosts

Open it as an administrator and edit the file, now add mapper which is going to point to our custom domain.

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
127.0.0.1 laravelamazon.com

Finally if you have your xampp started, restart the Apache and visit your custom domain name, then you will have the url opened on you local machine. Here is a laravel course that can help you using Laravel 8 bootstrap ui