DEV Community

Patrick Lusaya
Patrick Lusaya

Posted on • Edited on

How To Setup Laravel on Windows with XAMPP: Quick Guide

Welcome back to Laravel! Whether you're a beginner or a seasoned developer who's forgotten the basic setup, this quick guide will help you set up Laravel on Windows using XAMPP.

Follow me on twitter, I'll help you out with something ... I promise.

Lets get started

Step 1: Install PHP

First, you'll need PHP installed on your system. Laravel, being a PHP framework, requires PHP to function. You can download PHP from the official PHP website.

  • Click on the Windows Download

PHP Download Image

  • On the page where you are redirected, choose the thread-safe option and click on the zip link to download it.

redirected page

  • Once the zip file has been downloaded, extract it and copy the extracted folder into your program files folder located at


Local disk(C) -> Program files


Enter fullscreen mode Exit fullscreen mode
  • Now after pasting the folder, copy the its address.

copy address

  • On the start menu search for "Edit the system environment variables". Press enter to open it. A new window will appear then click on the "Environment Variables: button.

click environment

  • Another new window will appear and on the System Variables section, double-click on the Path to open up a new screen.

new pop up window

  • On that new screen, click on the new button. A field will appear. Paste the address copied previously and press OK on all screens to save your changes.

click the new button

  • To check if PHP is installed successfully, go to the start menu and open your terminal by typing cmd.

  • On the terminal type, php -v and press Enter to see the version of PHP installed.

check php version

Step 2: Install Composer
Composer is a dependency management tool for PHP which is required to install any PHP package/library you might want to use. Here's how to install it.

download composer

  • You will be redirected to the download page where you will have to click on the Composer-Setup.exe to download Composer on your machine.

redirected page

After the download is complete, Open the setup and select "install for all users"

  • For the next pop-up screens that appear click YES to allow installation then choose the installation type and press NEXT.

  • Select the command-line PHP path you want to use, check the box to add the PHP path, and click NEXT.

  • If you want to use a proxy, check the box and enter the proxy URL and if not proceed by clicking NEXT.

  • If everything seems okay, click the INSTALL button.

  • Read the information that follows after installation and click NEXT.

  • Finally, click the FINISH button to complete the installation.

Open your terminal and type "composer" to check if the installation was successful. If it was you will see the composer version and other composer commands

check if composer is installed

Step 3: Install XAMPP

  • Visit here and click on the Xampp for Windows link to start the download.

xampp install

  • Select MySQL, FileZilla ftp server, PHP, phpMyAdmin or you can just leave the default options and click the Next button.

  • In order to configure the htdocs folder for our apps, select the root directory path. Consider "C:\xampp."

  • To enable the XAMPP modules from the Windows firewall, click the Allow access button.

  • Click the XAMPP Setup wizard's Finish button after the installation is complete.

  • To start Xampp, go over to the start menu and type "xampp" then press enter to open it.

open xampp

  • To start the server, press the start button for Apache and Mysql, then the admin button of Mysql to open phpMyAdmin.

Now that you have PHP, Composer, and XAMPP installed, you can create a new Laravel project.

  • Since you are using xampp, the laravel project you are going to create should be within the xampp's htdocs folder found at


C:\xampp\htdocs


Enter fullscreen mode Exit fullscreen mode

.

  • Open the terminal at that location (


C:\xampp\htdocs


Enter fullscreen mode Exit fullscreen mode

) and run the command composer global require "laravel/installer" to install laravel

install laravel

  • Then run laravel new my_app on the same path (C:\xampp\htdocs) to create a project called "my_app"

  • Now go inside Laravel folder and run php artisan serve command.

start project

  • If everything goes well, the command will launch a local development server on port 8000. You can access your Laravel application by opening your web browser and navigating to http://localhost:8000.

That's it! You've now successfully set up Laravel on Windows using XAMPP.

If, I've just saved your day follow me on twitter and I'll save you another

Happy coding!

Top comments (5)

Collapse
 
filo_bus_e99bd7812b5914b8 profile image
Filo Bus • Edited

I don't understand why you use artisan serve if you started xampp: you either use one or the other one, imho

Collapse
 
khalilksa33 profile image
Khalil Ahmad Yaqoob

yes this was my question also?

Collapse
 
vic_torio_fc736e9b66ffdec profile image
Vic Torio

agree

Collapse
 
keyvan_akbarzadeh_4088015 profile image
Keyvan Akbarzadeh

this is totally wrong!!

Collapse
 
kbright profile image
Kevin Bright

Thank you so much!!!