How to install Laravel 12?

How to install Laravel 12

Laravel is one of the most popular PHP frameworks in the world, known for its elegant syntax, modern features, and ability to streamline web application development. With the release of Laravel 12, developers get even more powerful tools, performance improvements, and security enhancements, making it an ideal choice for building scalable, maintainable, and high-quality applications.

Whether you’re creating a small website, a large enterprise application, or an API backend, Laravel offers a complete development ecosystem, including:

  • A clean and expressive routing system.
  • Powerful ORM (Eloquent) for working with databases.
  • Built-in authentication, queue handling, and caching.
  • Integration with modern frontend tools via Vite.

Why install Laravel 12?

  • Access to the latest PHP 8.2+ features and performance improvements.
  • Improved developer experience with updated Artisan commands and tooling.
  • Better security and long-term support for modern web applications.
  • Compatibility with the latest ecosystem packages and Laravel updates.

In this guide, we’ll walk through the step-by-step process of installing Laravel 12 on your local machine — from checking system requirements to starting your first Laravel project. By the end, you’ll have a fully functional Laravel environment ready for development.

Step 1 – Check Prerequisites 

Before installing Laravel 12, ensure the following are installed with the correct versions:

a) PHP → Must be 8.2 or higher (Laravel 12 will not run on lower versions).

   php -v

Expected Output Example:

   PHP 8.2.12 (cli) (built: ...)

b) – ComposerVersion 2.5 or higher recommended.

   composer -V

Expected Output Example:

   Composer version 2.7.2 2024-04-18 12:00:00

c) Node.jsVersion 18+ recommended (LTS version preferred).

   node -v

Expected Output Example:

   v18.17.1

d) npmVersion 9+ recommended.

   npm -v

Expected Output Example:

   9.6.7

e ) Web Server → Apache or Nginx

f ) Database → MySQL 8+, PostgreSQL 13+, SQLite 3.35+, or SQL Server 2019+.

Step 2 – Create a New Laravel Project

Run the following Composer command to install Laravel (latest version):

composer create-project laravel/laravel example-app
  • If you provide database credentials later, Laravel will use them.
  • If no database is configured, Laravel will default to SQLite located at:
  database/database.sqlite

Step 3 – Configure Database (MySQL Example)

Edit the .env file in your project root:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

💡 Replace root and the password with your actual database credentials.


Step 4 – Run Database Migrations

php artisan migrate

This will create the necessary tables in your database.


Step 5 – Install Frontend Dependencies

npm install && npm run build
  • For development mode with auto-refresh:
  npm run dev

Step 6 – Start the Laravel Development Server

php artisan serve

Open your browser and visit:
http://localhost:8000 🎉