🎉🎉 Larasense is officially launched 🎉🎉
- Your Hub for Laravel News, Trends & Updates

How to Install Laravel and Composer on Windows and Get Started

laravel
tutorial
install
Nabil Hassen
Nabil Hassen
Dec 27, 2024
Install Laravel on Windows
Last updated on Dec 26, 2024
Table of contents:

If you’re new to Laravel and web development, getting started might seem overwhelming. But don’t worry—this guide will walk you through the process of installing Laravel 11 on a Windows system step by step. By the end, you’ll have a fully functional Laravel environment ready to build your next project.

Step 1: Install PHP and Composer

Laravel requires PHP and Composer (a dependency manager for PHP). Thankfully, there’s an easy way to install both:

  1. Open Windows PowerShell with administrator privileges.

  2. Run the following command:

    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))

    This command installs PHP 8.4 and Composer. Restart your terminal after installation to apply the changes.

Step 2: Install the Laravel Installer

With Composer installed, you can now globally install the Laravel installer. Run the following command in PowerShell:

composer global require laravel/installer

This will make the laravel command available globally on your system.

Step 3: Create a New Laravel Application

  1. Navigate to the folder where you want to create your Laravel project. For example:

    cd C:\Projects
  2. Create a new Laravel application by running:

    laravel new example-app
  3. Follow the prompts to configure your project’s testing framework, database, and starter kit.

Step 4: Install Node.js and NPM

Laravel uses Node.js and NPM to manage frontend assets. Follow these steps:

  1. Download and install the latest LTS version of Node.js from nodejs.org.
  2. During installation, ensure that you select the option to include NPM (Node Package Manager).

Step 5: Set Up Frontend Dependencies

  1. Navigate to your project directory:

    cd example-app
  2. Install the necessary frontend dependencies:

    npm install

This installs the packages listed in your package.json file.

Step 6: Build Frontend Assets

After installing the dependencies, build the frontend assets by running:

npm run build

This compiles your application’s CSS and JavaScript files.

Step 7: Start the Development Server

To start the Laravel development server, run:

composer run dev

This command starts the local development server, queue worker, and Vite development server. Your application will be accessible at:

http://localhost:8000

Step 8: Configure Your Environment

Laravel uses a .env file in the project root to manage configuration settings like database credentials and application environment. Open this file and update it with your specific setup.

Step 9: Set Up a Database (Optional)

By default, the .env configuration file specifies that Laravel will interact with an SQLite database. If you’re comfortable using SQLite, Laravel is already set up for you. However, if you’d like to use a different database system, follow these steps:

  1. Update the .env file with your database settings. For example, to use MySQL:

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=root
    DB_PASSWORD=
  2. Run migrations to create the necessary database tables:

    php artisan migrate

You’re All Set!

Congratulations! You’ve successfully installed Laravel 11 on your Windows system. You’re now ready to start developing your application. If you have any questions or run into issues, Laravel’s official documentation is an excellent resource to consult. For beginners, check out the Laravel Bootcamp for a hands-on tour of the framework while walking you through building your first Laravel application.

Welcome to Laravel!

Nabil Hassen
Nabil Hassen
Full Stack Web Developer

Stay Updated.

I'll you email you as soon as new, fresh content is published.

Thanks for subscribing to my blog.

Latest Posts

Larasenes Logo
Larasense
Stay updated on Laravel news, trends, and updates with curated content from top blogs, YouTube, and podcasts in a sleek, user-friendly design.