How to Install Laravel on Windows 11 for Beginners
Table of Contents
Introduction
This tutorial provides a step-by-step guide on how to install Laravel 9 on Windows 11 using XAMPP, Composer, and Git Bash. Whether you're a beginner or looking to refresh your skills, this guide will help you set up a development environment for Laravel efficiently.
Step 1: Install XAMPP
-
Download XAMPP
- Visit the XAMPP website: Apache Friends.
- Choose the version compatible with Windows and download the installer.
-
Run the Installer
- Open the downloaded file and follow the installation prompts.
- Select components to install; ensure "Apache" and "MySQL" are checked.
- Choose the installation directory (the default is usually fine).
-
Start XAMPP
- Open the XAMPP Control Panel after installation.
- Start the "Apache" and "MySQL" services by clicking the respective "Start" buttons.
Step 2: Install Composer
-
Download Composer
- Go to the Composer website: Get Composer.
- Download the Composer-Setup.exe file.
-
Run the Installer
- Open the downloaded file.
- During installation, when prompted for the PHP executable, navigate to the PHP folder in your XAMPP installation (e.g.,
C:\xampp\php\php.exe).
-
Verify Installation
- Open Command Prompt or Git Bash.
- Type
composer -vand press Enter. You should see the version of Composer installed.
Step 3: Install Git Bash
-
Download Git Bash
- Access the Git website: Git for Windows.
- Download the latest version of Git for Windows.
-
Run the Installer
- Open the downloaded file and follow the prompts.
- Choose the default options during installation for simplicity.
-
Verify Installation
- Open Git Bash.
- Type
git --versionto confirm that Git is installed correctly.
Step 4: Install Node.js
-
Download Node.js
- Visit the Node.js website: Node.js.
- Download the LTS version for Windows.
-
Run the Installer
- Open the downloaded file and follow the installation prompts.
- Ensure you install the necessary tools for Node.js.
-
Verify Installation
- Open Command Prompt or Git Bash.
- Type
node -vandnpm -vto check that both Node.js and npm are installed correctly.
Step 5: Download and Set Up Laravel
-
Create a New Laravel Project
- Open Git Bash and navigate to the
htdocsdirectory in XAMPP (e.g.,cd C:/xampp/htdocs). - Run the following command to create a new Laravel project:
composer create-project --prefer-dist laravel/laravel your-project-name - Replace
your-project-namewith the desired name for your project.
- Open Git Bash and navigate to the
-
Configure Environment File
- Navigate to your project folder:
cd your-project-name. - Copy the
.env.examplefile to create a new.envfile:cp .env.example .env - Open the
.envfile in Visual Studio Code (download from Visual Studio Code) and set your database credentials.
- Navigate to your project folder:
-
Generate Application Key
- In the terminal, run:
php artisan key:generate
- In the terminal, run:
Conclusion
You have successfully installed Laravel 9 on Windows 11 using XAMPP, Composer, Git Bash, and Node.js. You can now start building your applications. As a next step, explore the Laravel documentation to familiarize yourself with its features and functionalities. Happy coding!