How To Setup Laravel on Windows with XAMPP: Quick Guide
Tags: laravel, xampp, windows
Published: 2024-01-24 12:25:23

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.

**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](https://www.php.net/downloads).

- Click on the Windows Download


![PHP Download Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/po6uwyrdb1kol5y3iuhp.png)

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


![redirected page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gqi9ggjo85mjesjs2cmx.png)

- 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
```

- Now after pasting the folder, copy the its address.

![copy address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fq9zvv1jkgr5hqfiy9dd.png)

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjq65lr20y7wzv8d6tmm.png)

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uafl3k4ltaisnc9hy1cr.png)

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eeau3rimkoohlp6l70ks.png)


- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9e4jfwkrwmc39tz9cd7b.png)


**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.

- Visit [https://getcomposer.org/](https://getcomposer.org/) and click on the DOWNLOAD button.

![download composer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xgrkk1idcmt2w2dkuk4.png)

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bmmq5y8zrghol98p0jz.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2lm972x6yt0i3cp8sn1.png)

**Step 3: Install XAMPP**

- Visit [here](https://www.apachefriends.org/index.html) and click on the Xampp for Windows link to start the download.



![xampp install](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v18685ydiofdteid7602.png)
- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cogi49hqw0huxqvs1kkw.png)

- 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
```
.

- Open the terminal at that location (

```
C:\xampp\htdocs
```
) and run the command `composer global require "laravel/installer"` to install laravel 

![install laravel ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oesolbctcvqsc21gq5zm.png)

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35qz82zm6xyjs02d8oug.png)

- 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. Happy coding!