How to Install Laravel 12: Step-by-Step Guide

October 04, 2025

Laravel is one of the most popular PHP frameworks for building modern web applications. Laravel 12 comes with improved features, better performance, and robust tools for developers. In this guide, we will walk through the installation process from scratch.

Prerequisites

Before installing Laravel 12

make sure your system has the following installed:

  1. PHP >= 8.2 Composer (PHP dependency manager)
  2. MySQL / MariaDB (or any database supported by Laravel)
  3. Node.js & NPM (for frontend assets, optional but recommended)
  4. Web Server (Apache, Nginx, or Laravel’s built-in server)

You can check PHP and Composer versions by running:

php -v composer -V 

Step 1: Install Composer

Laravel uses Composer to manage dependencies. If you don’t have it installed:

  1. Go to https://getcomposer.org/download/
  2. Follow the installation instructions for your operating system.
  3. Verify installation:
composer -V 

Step 2: Create a New Laravel 12 Project

Run the following command to create a new Laravel project:

composer create-project laravel/laravel:^12.0 my-laravel-app 

Here, my-laravel-app is the name of your project folder. Composer will download all dependencies and set up Laravel for you.

Step 3: Set Up Environment Variables

Navigate into your project folder:

cd my-laravel-app 

Laravel uses a .env file for configuration. Copy the default example file:

 cp .env.example .env 

Update the following values in .env according to your setup:

APP_NAME="MyLaravelApp" 
APP_URL=http://localhost 
DB_CONNECTION=mysql 
DB_HOST=127.0.0.1 
DB_PORT=3306 
DB_DATABASE=laravel_db 
DB_USERNAME=root 
DB_PASSWORD= 

Make sure you create the database (laravel_db) in MySQL before running migrations.

Step 4: Generate Application Key

Laravel requires an application key for security. Generate it by running:

php artisan key:generate 

You should see:

 Application key set successfully.

This will update the APP_KEY in your .env file.

Step 5: Run Migrations

Laravel comes with built-in authentication and other tables. Run migrations to create them in your database:

php artisan migrate 

If successful, your database now has the default tables like users, password_resets, etc.

Step 6: Start the Development Server

You can start Laravel’s built-in server to see your application in action:

php artisan serve

Visit http://localhost:8000 in your browser. You should see the Laravel welcome page!

Step 7: Optional – Install Node Dependencies

If you plan to use Laravel Mix or build frontend assets (CSS, JS), install Node dependencies:

npm install 
npm run dev