All 15 Developer & Utility Tools are 100% Free & Client-Side Private!
8667596915 • 2kwebsolutionz@gmail.com
Laravel Tutorials

How to Install Laravel on Windows Using XAMPP

By 2K Admin • November 28, 2026 • 13 min read • 2 views
How to Install Laravel on Windows Using XAMPP
Laravel is one of the most popular PHP frameworks for building modern websites and web applications.

If you are a beginner and want to learn Laravel on Windows, you can use XAMPP to set up your local development environment.

In this tutorial, you will learn how to install Laravel on Windows using XAMPP, configure PHP and Composer, create a Laravel project, connect MySQL, and run your first Laravel application.

What Is Laravel?

Laravel is an open-source PHP framework designed to make web application development easier, faster, and more organized.

It follows the Model-View-Controller (MVC) architecture and provides built-in tools for handling common development tasks.

Some important Laravel features include:

  • MVC architecture.
  • Routing and controllers.
  • Blade templating engine.
  • Authentication and authorization.
  • Database migrations.
  • Eloquent ORM.
  • REST API development.
  • Form validation.
  • Middleware.
  • Security features.

Laravel is commonly used to develop business websites, eCommerce platforms, CRM systems, admin dashboards, booking applications, and SaaS platforms.

What Is XAMPP?

XAMPP is a free local development environment that provides the services needed to run PHP applications on your computer.

It includes:

  • Apache – Web server.
  • MariaDB – Database server.
  • PHP – Server-side programming language.
  • phpMyAdmin – Database management interface.

XAMPP allows developers to create and test PHP applications locally without purchasing hosting or deploying a website to the internet.

Download XAMPP: https://www.apachefriends.org/

Requirements to Install Laravel on Windows

Before installing Laravel, make sure your computer has the following software:

| Software | Purpose |
|---|---|
| Windows 10 or 11 | Operating system |
| XAMPP | PHP and database environment |
| PHP 8.3 or higher | Required for Laravel 13 |
| Composer | PHP dependency manager |
| Visual Studio Code | Code editor |
| Node.js and npm | Front-end asset management |

Important: This tutorial uses Laravel 13. Laravel 13 requires PHP 8.3 or higher. Check your XAMPP PHP version before creating the project. If your XAMPP installation has an older PHP version, install a compatible XAMPP release or configure a separate supported PHP version for Composer.

Step 1: Download and Install XAMPP

First, download XAMPP for Windows.

  1. Visit https://www.apachefriends.org/download.html.
  2. Download a XAMPP version with PHP 8.3 or higher.
  3. Run the downloaded installer.
  4. Select Apache, MySQL/MariaDB, PHP, and phpMyAdmin.
  5. Install XAMPP in the following directory:
TEXT
C:\xampp

6. Complete the installation.

After installation, open the XAMPP Control Panel.

Start the following services:

  • Apache
  • MySQL

If both services start successfully, your local PHP and database environment is ready.

To verify XAMPP, open your browser and visit:

TEXT
http://localhost/

You should see the XAMPP dashboard.

Step 2: Check the PHP Version

Laravel requires a supported PHP version to run properly.

Open Command Prompt or PowerShell and execute:

Terminal / CLI
php -v

You should see the PHP version installed on your system.

For Laravel 13, the PHP version must be 8.3 or higher.

If you get the following error:

TEXT
'php' is not recognized as an internal or external command

You need to add the XAMPP PHP directory to your Windows PATH environment variable.

Add XAMPP PHP to Windows PATH

  1. Search for Environment Variables in Windows.
  2. Open Edit the system environment variables.
  3. Click Environment Variables.
  4. Under System variables, select Path.
  5. Click Edit.
  6. Click New and add:
TEXT
C:\xampp\php
  1. Save the changes.
  2. Close and reopen Command Prompt.

Now execute:

Terminal / CLI
php -v

You should see the PHP version from your XAMPP installation.

Important: If you have multiple PHP installations, Windows may use a different PHP executable. Run this command to check:

Terminal / CLI
where php

Make sure the XAMPP PHP executable is the one being used when you run Composer.

Step 3: Configure PHP Extensions

Laravel and its dependencies require certain PHP extensions.

Open the following file:

TEXT
C:\xampp\php\php.ini

Search for the following extensions:

INI
extension=curl
extension=fileinfo
extension=mbstring
extension=openssl
extension=pdo_mysql
extension=zip
extension=xml
extension=intl

If any required extension is commented out with a semicolon, remove the semicolon.

For example:

INI
;extension=mbstring

Change it to:

INI
extension=mbstring

Save the file.

Restart Apache from the XAMPP Control Panel so that Apache loads the updated PHP configuration.

To check whether an extension is enabled in your command-line PHP configuration, execute:

Terminal / CLI
php -m

Check that the required extensions are listed.

Note: Command-line PHP and Apache PHP can use different php.ini files if multiple PHP installations are present. Check the active CLI configuration using:

Terminal / CLI
php --ini

Step 4: Install Composer on Windows

Composer is a dependency manager for PHP. Laravel uses Composer to download and manage the framework and its packages.

To install Composer:

  1. Visit https://getcomposer.org/download/.
  2. Download Composer-Setup.exe.
  3. Run the installer.
  4. When prompted to select the PHP executable, choose:
TEXT
C:\xampp\php\php.exe
  1. Complete the installation.
  2. Close and reopen Command Prompt.

Verify the installation:

Terminal / CLI
composer -V

You should see the installed Composer version.

If Composer reports a PHP version different from your XAMPP version, check the PHP executable selected during Composer installation.

Step 5: Create a New Laravel Project

Now that PHP and Composer are installed, you can create your first Laravel project.

Open Command Prompt or PowerShell.

Navigate to the folder where you want to store your Laravel projects.

For example:

Terminal / CLI
cd C:\xampp\htdocs

Execute the following Composer command:

Terminal / CLI
composer create-project laravel/laravel my-laravel-app

This command will:

  • Download the Laravel application.
  • Install the required Composer packages.
  • Create the Laravel project directory.
  • Generate the application structure.
  • Prepare the application environment.

Wait until Composer finishes installing all dependencies.

Your Laravel project will be created inside:

TEXT
C:\xampp\htdocs\my-laravel-app

You can also create a project in another directory outside htdocs if you plan to run it using Laravel's built-in development server.

Step 6: Open the Laravel Project in Visual Studio Code

After creating your Laravel application, open it in Visual Studio Code.

You can execute:

Terminal / CLI
cd my-laravel-app
code .

If the code command is unavailable, open Visual Studio Code manually and select:

File → Open Folder → my-laravel-app

You should see the following Laravel project structure:

TEXT
my-laravel-app/
│
├── app/
├── bootstrap/
├── config/
├── database/
├── public/
├── resources/
├── routes/
├── storage/
├── tests/
├── vendor/
│
├── .env
├── artisan
├── composer.json
├── package.json
└── vite.config.js

Some important directories:

  • app/ – Application logic, models, and other PHP classes.
  • bootstrap/ – Framework bootstrapping files.
  • config/ – Application configuration files.
  • database/ – Migrations, seeders, and factories.
  • public/ – Public entry point and assets.
  • resources/ – Blade templates, CSS, and JavaScript source files.
  • routes/ – Application route definitions.
  • storage/ – Logs, cache, and uploaded or generated files.
  • vendor/ – Composer dependencies.

Step 7: Generate the Laravel Application Key

Laravel uses an application encryption key to protect encrypted data and application sessions.

Open the terminal inside your Laravel project directory and execute:

Terminal / CLI
php artisan key:generate

Laravel will automatically update the APP_KEY value in your .env file.

You should see a success message confirming that the application key was generated.

Step 8: Create a MySQL Database Using phpMyAdmin

Now let's connect Laravel to the XAMPP database server.

First, open your browser and visit:

TEXT
http://localhost/phpmyadmin

Follow these steps:

  1. Open phpMyAdmin.
  2. Click the New option.
  3. Enter the database name:
TEXT
laravel_db
  1. Select a suitable collation, such as utf8mb4_unicode_ci.
  2. Click Create.

Your database is now ready.

Step 9: Configure Laravel Database Connection

Open the .env file in your Laravel project.

Find the database configuration and update it as follows:

ENV
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=

These are common default XAMPP local database settings. If you have configured a database password or changed the MySQL/MariaDB port, update the values accordingly.

Save the .env file.

Step 10: Run Laravel Database Migrations

Laravel uses migrations to create and modify database tables.

Open the terminal inside your Laravel project directory and execute:

Terminal / CLI
php artisan migrate

Laravel will create the default database tables required by the application.

If the migration completes successfully, your Laravel application is connected to the database.

You can verify the created tables by opening phpMyAdmin and selecting laravel_db.

Step 11: Run the Laravel Application

You are now ready to run your first Laravel application.

Open Command Prompt inside the project directory:

Terminal / CLI
php artisan serve

You should see output similar to:

TEXT
INFO  Server running on [http://127.0.0.1:8000].

Open your browser and visit:

TEXT
http://127.0.0.1:8000

You should see the Laravel welcome page.

<em>Congratulations! Your Laravel application is running successfully on Windows.</em>

Step 12: Run Front-End Assets Using Node.js and npm

Modern Laravel projects use Vite to manage and compile front-end assets.

If your project includes a package.json file, install Node.js from:

https://nodejs.org/

After installation, verify Node.js and npm:

Terminal / CLI
node -v
npm -v

Navigate to your Laravel project directory and execute:

Terminal / CLI
npm install

To compile the front-end assets for development, run:

Terminal / CLI
npm run dev

Keep this terminal running while developing.

To generate production-ready assets, execute:

Terminal / CLI
npm run build

Step 13: Create Your First Laravel Route

Let's create a simple route to understand how Laravel works.

Open:

TEXT
routes/web.php

Add the following code:

PHP
use Illuminate\Support\Facades\Route;

Route::get('/welcome', function () {
    return 'Welcome to Laravel Development!';
});

Save the file and visit:

TEXT
http://127.0.0.1:8000/welcome

You should see:

TEXT
Welcome to Laravel Development!

This is your first Laravel route.

Step 14: Run Laravel Using Apache in XAMPP (Optional)

You can also configure Apache to serve your Laravel project.

However, Laravel's built-in development server using php artisan serve is usually easier for beginners.

If you want to use Apache, configure a virtual host so that its document root points to the Laravel project's public directory.

For example, add the following configuration to your Apache virtual hosts file:

APACHE
<VirtualHost *:80>
    ServerName laravel.local
    DocumentRoot "C:/xampp/htdocs/my-laravel-app/public"

    <Directory "C:/xampp/htdocs/my-laravel-app/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Also make sure Apache's virtual hosts configuration is enabled and that mod_rewrite is active.

Add this entry to the Windows hosts file, usually located at:

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

Add:

TEXT
127.0.0.1 laravel.local

Restart Apache and visit:

TEXT
http://laravel.local

Security note: Apache's document root must point to the Laravel public directory, not the project root. Never expose .env, vendor, storage, or other internal application directories through the web server.

Common Laravel Installation Errors and Solutions

1. PHP Version Error

You may encounter an error such as:

TEXT
Your Composer dependencies require a PHP version >= 8.3.0.
You are running 8.2.x.

Solution:

  • Check the PHP version using php -v.
  • Run where php to identify the executable being used.
  • Install a compatible PHP version.
  • Make sure Composer uses the correct PHP executable.
  • Restart your terminal and try again.

2. Composer Is Not Recognized

Error:

TEXT
'composer' is not recognized as an internal or external command.

Solution:

  • Install Composer using the official Windows installer.
  • Check whether Composer was added to the Windows PATH.
  • Restart Command Prompt or PowerShell.
  • Execute composer -V again.

3. PHP Extension Missing

You may see an error indicating that a required PHP extension is missing.

Solution:

  • Open C:\xampp\php\php.ini.
  • Enable the required extension.
  • Save the file.
  • Restart Apache if needed.
  • Check CLI extensions using php -m.
  • Run the Composer installation command again.

4. MySQL Connection Error

You may encounter:

TEXT
SQLSTATE[HY000] [2002] Connection refused

Solution:

  • Start MySQL from the XAMPP Control Panel.
  • Check the database name.
  • Verify the database username and password.
  • Check whether MySQL/MariaDB is running on port 3306.
  • Clear cached Laravel configuration:
Terminal / CLI
php artisan config:clear

5. Apache Port 80 Already in Use

Apache may fail to start because another application is using port 80.

Solution:

  • Check which application is using port 80.
  • Stop the conflicting service or configure Apache to use another port.
  • Restart Apache.

6. Laravel Application Key Missing

If you see an application key error, execute:

Terminal / CLI
php artisan key:generate

Useful Laravel Artisan Commands for Beginners

Here are some commonly used Laravel commands:

| Command | Purpose |
|---|---|
| php artisan serve | Start the local development server |
| php artisan key:generate | Generate application encryption key |
| php artisan migrate | Run database migrations |
| php artisan make:model User | Create a model |
| php artisan make:controller UserController | Create a controller |
| php artisan make:migration create_posts_table | Create a migration |
| php artisan route:list | Display application routes |
| php artisan config:clear | Clear configuration cache |
| php artisan cache:clear | Clear application cache |
| php artisan optimize:clear | Clear Laravel optimization caches |

Frequently Asked Questions

1. Can I install Laravel using XAMPP?

Yes. You can use XAMPP to provide PHP and MySQL/MariaDB for Laravel development. You also need Composer to install Laravel and its dependencies.

2. Which PHP version is required for Laravel 13?

Laravel 13 requires PHP 8.3 or higher. Always check the official Laravel documentation for the requirements of the version you intend to install.

3. Do I need Composer to install Laravel?

Yes. Composer is used to download Laravel and manage its PHP dependencies.

4. Where should I install Laravel in XAMPP?

You can create your Laravel project inside C:\xampp\htdocs. Alternatively, you can store it outside the XAMPP directory and run it using Laravel's built-in development server.

5. Can I run Laravel without starting Apache?

Yes. You can run Laravel using:

Terminal / CLI
php artisan serve

This starts Laravel's built-in development server. You can still use the XAMPP MySQL/MariaDB service for your database.

6. Can I use phpMyAdmin with Laravel?

Yes. You can use phpMyAdmin to create databases, view tables, manage records, and inspect your Laravel database.

7. Can I use Visual Studio Code for Laravel development?

Yes. Visual Studio Code is a popular code editor for Laravel development. You can use extensions for PHP, Blade templates, Laravel Artisan commands, and code formatting.

8. Is XAMPP enough for Laravel development?

XAMPP provides the local PHP and database environment, but you also need Composer. Modern Laravel projects may additionally require Node.js and npm to compile front-end assets.

9. Can I install Laravel 12 using XAMPP?

Yes. You can install Laravel 12 using Composer if your PHP version meets the requirements of that Laravel release. Check the official documentation before selecting a framework version.

10. Can I host a Laravel project online after developing it using XAMPP?

Yes. You can deploy your Laravel application to a compatible hosting server. Make sure the server meets Laravel's PHP and extension requirements, and configure the web server to serve the application's public directory.

Conclusion

Installing Laravel on Windows using XAMPP is a practical way to begin PHP framework development.

By installing XAMPP, configuring PHP, setting up Composer, creating a Laravel project, and connecting a database, you can build and test Laravel applications on your local computer.

Once your environment is ready, start learning Laravel routes, controllers, models, Blade templates, database migrations, and CRUD operations.

Practice by building small projects and gradually move towards complete web applications.

Learn More About Web Development

At 2K Web Solutions, we share practical tutorials and resources covering PHP, Laravel, WordPress, MySQL, web development, and SEO.

Explore more tutorials and improve your web development skills.

Need a custom Laravel application? Explore our [Website Development Services](https://2kwebsolutions.com/website-development-services).

Enjoyed this tutorial? Share it with other developers!

Related Tech Articles

Laravel CRUD Application Tutorial: Step-by-Step Guide for Beginners

In this tutorial, you will learn how to build a complete Laravel CRUD application from scratch using Laravel 13, MySQL, Bootstrap 5, and Blade templates.

Read More
Laravel 13 Tutorial for Beginners: Complete Guide

Introduction Laravel is one of the most popular PHP frameworks for developing...

Read More