How to Install Laravel on Windows 11 for Beginners

3 min read 1 year ago
Published on Aug 19, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

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

  1. Download XAMPP

    • Visit the XAMPP website: Apache Friends.
    • Choose the version compatible with Windows and download the installer.
  2. 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).
  3. 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

  1. Download Composer

    • Go to the Composer website: Get Composer.
    • Download the Composer-Setup.exe file.
  2. 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).
  3. Verify Installation

    • Open Command Prompt or Git Bash.
    • Type composer -v and press Enter. You should see the version of Composer installed.

Step 3: Install Git Bash

  1. Download Git Bash

    • Access the Git website: Git for Windows.
    • Download the latest version of Git for Windows.
  2. Run the Installer

    • Open the downloaded file and follow the prompts.
    • Choose the default options during installation for simplicity.
  3. Verify Installation

    • Open Git Bash.
    • Type git --version to confirm that Git is installed correctly.

Step 4: Install Node.js

  1. Download Node.js

    • Visit the Node.js website: Node.js.
    • Download the LTS version for Windows.
  2. Run the Installer

    • Open the downloaded file and follow the installation prompts.
    • Ensure you install the necessary tools for Node.js.
  3. Verify Installation

    • Open Command Prompt or Git Bash.
    • Type node -v and npm -v to check that both Node.js and npm are installed correctly.

Step 5: Download and Set Up Laravel

  1. Create a New Laravel Project

    • Open Git Bash and navigate to the htdocs directory 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-name with the desired name for your project.
  2. Configure Environment File

    • Navigate to your project folder: cd your-project-name.
    • Copy the .env.example file to create a new .env file:
      cp .env.example .env
      
    • Open the .env file in Visual Studio Code (download from Visual Studio Code) and set your database credentials.
  3. Generate Application Key

    • In the terminal, run:
      php artisan key:generate
      

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!