Setting up a Laravel project on Windows with XAMPP

Step-by-step guide on how to setup XAMPP for your PHP and Laravel applications.

Download and install

Download XAMPP and install.

After installation set a password for root user in MySql Database. Start Apache, MySql in XAMPP control panel, open Shell from the right menu and execute the following

mysqladmin.exe -u root password your_new_password

Go to XAMPP directory > phpMyAdmin and open the file. Add your new password in the configuration settings.

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'your_new_password';

Restart XAMPP and you have successfully setup.

GIT and Node

Download and install the latest versions of Git, Node.

You can skip installing both of them for later if you want.

Psst, If you want to update any of them, uninstall the older version, download the newer version and install again.


It’s our dependency manager. Get the .exe file from the official site.

Run the installer and in midway it asks for php.exe path. Browse for Xampp > Php > php.exe and we are done. After installing, it prompts three steps to follow. Do it and we have setup Composer too.

Checking GIT, Node and Composer

Let’s check whether everything has been installed correctly. Right click anywhere on the desktop/ File explorer, open Git Bash. Type the following commands

git --version
node -v
npm -v

Laravel Installer

Go to XAMPP > htdocs Right click > Git bash here.

You need Laravel installer to create a new Laravel project. You need to run the following command only once.

composer global require "laravel/installer"

After installing, you can create a fresh project using the following command.

Laravel new your_project_name

You can see a new directory your_project_name in htdocs. Move into the project folder and open git bash again there. Let’s make up the project.

Making up the project

composer install

Check whether the project has .env file. If not, rename .env.example to .env

Change the DB settings in the .env file

Laravel Mix for Front-end

You can change your front-end dependencies in package.json file.

npm install
npm install --no-bin-links

Virtual Host

On XAMPP Let’s setup or Dev virtual host.

Go to F:\xampp\apache\conf\extra and open httpd-vhosts.conf file and add the following lines. You need to change Document Root and Servername ( also the logs if needed.)

<VirtualHost *:80>
DocumentRoot "F:/xampp/htdocs/your_new_project/public"
##ErrorLog "logs/"
##CustomLog "logs/" common

Open notepad with Administrator rights.

Open the file C:\Windows\System32\drivers\etc and open hosts file and add your Servername.

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

Remember to restart Apache every time you change XAMPP configuration settings or .env file settings.