How to install laravel?
Laravel is a modern PHP framework designed for building secure, scalable, and maintainable web applications. Below are the correct and up-to-date steps to install and set up a Laravel 12 project in 2026 on Windows, macOS, and Linux.
System Requirements (Laravel 12)
- PHP 8.2 or higher (PHP 8.3 / 8.4 recommended for better performance)
- Composer (latest version)
- Node.js & npm (for frontend assets and Vite)
- SQLite, MySQL, or PostgreSQL
Install Required Software
Windows
- Install PHP 8.3+ or use Laravel Herd (recommended)
- Install Composer from getcomposer.org
- Install Node.js (LTS)
- Optional: Enable WSL2 for Linux-based tooling
macOS
- Install Laravel Herd (recommended)
- Composer and PHP are included with Herd
- Install Node.js (LTS)
Linux
- Install PHP via apt, dnf, or pacman
- Install Composer globally
- Install Node.js (NodeSource or distro packages)
Create a New Laravel 12 Project
The Laravel Installer is the recommended way to create new projects in Laravel 12. It automatically configures the environment file, application key, and database.
laravel new example-appDuring installation, you will be prompted to choose:
- Database (SQLite, MySQL, PostgreSQL)
- Starter kit (None, Blade, Livewire, React, Vue)
- Testing framework (Pest or PHPUnit)
Project Environment Configuration
In Laravel 12, the installer automatically creates the .env file and generates the application key. No manual setup is required for new projects.
You may review or adjust settings later inside the .env file if needed.
Database Setup
SQLite (Default and Recommended for Local Development)
If SQLite is selected during installation, Laravel automatically configures and manages the database file.
DB_CONNECTION=sqliteIf the database file does not exist, Laravel will offer to create it automatically when running migrations.
MySQL Example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=Run Database Migrations
If migrations were not executed during the installation wizard, run:
php artisan migrateStart the Development Environment
Laravel 12 provides a unified development command that runs the PHP server, Vite, and background services together.
composer devThe application will be available at: http://localhost
Docker Setup Using Laravel Installer (Optional)
For Docker-based development, Laravel 12 recommends using the installer flag instead of manual Sail commands.
laravel new example-app --dockerAfter installation, start the containers:
cd example-app
./vendor/bin/sail upRecommended Next Steps
- Learn routing, controllers, and middleware
- Understand Eloquent ORM and migrations
- Use Blade, Livewire, or Inertia for UI
- Build frontend assets with Vite
- Explore authentication starter kits
Related Answers
Still need help?
Talk to our Laravel experts
We've handled GDPR/CCPA compliance for dozens of EU & US Laravel.
