Laravel 12 is the latest and most powerful version of the popular PHP framework known for its elegant syntax, developer-friendly features, and robust performance. In this tutorial, we will guide you through a step-by-step Laravel 12 installation process on your local machine or server.
🛠️ Prerequisites
Before you begin, make sure your system meets the following requirements:
✅ Server Requirements
- PHP 8.2 or higher
- Composer (latest version)
- PHP Extensions:
BCMath
- Ctype
- Fileinfo
- JSON
- Mbstring
- OpenSSL
- PDO
- Tokenizer
- XML
- Curl
To check if Composer is installed:
📥 Step 1: Install Laravel 12 Using Composer
Open your terminal and run the following command:
my-laravel-app
is your project directory name. You can change it as per your project.- This command will download Laravel 12 and all its dependencies.
Laravel 12 requires Composer 2.0 or later.
📁 Step 2: Move Into Your Project Directory
⚙️ Step 3: Set File Permissions (Linux/macOS)
Make sure the storage/
and bootstrap/cache/
directories are writable:
🧪 Step 4: Run Laravel Development Server
Laravel comes with a built-in development server. You can start it with:
This will start the server at:
Open this URL in your browser to see your new Laravel 12 project in action!
⚡ Step 5: Configure Environment File
Laravel uses .env
file to manage environment-specific settings like database credentials.
Make sure to create and configure your .env
file:
Edit your .env
file to set database and mail configuration:
💾 Step 6: Set Up Database (Optional but Recommended)
To use Laravel with MySQL:
- Create a new database in MySQL.
- Configure
.env
file as shown above. - Run migrations:
🌐 Optional: Set Virtual Host (Apache)
If you prefer accessing Laravel via a custom domain like http://laravel.test
, set up a virtual host:
Example Apache Vhost:
Add entry in hosts
file:
Add this line:
Then restart Apache:
🧩 Optional: Install Laravel Breeze (Starter Kit)
To quickly scaffold authentication:
✅ Laravel 12 Installation Complete!
You’re now ready to start building amazing web applications with Laravel 12!
📝 Final Checklist
Task | Status |
---|---|
Composer Installed | ✅ |
Laravel 12 Created | ✅ |
.env Configured |
✅ |
Database Connected | ✅ |
Dev Server Working | ✅ |
Optional Features Installed | 🚫/✅ |
📚 Useful Commands
Command | Description |
---|---|
php artisan serve |
Start development server |
php artisan migrate |
Run database migrations |
php artisan make:model |
Create new Eloquent model |
php artisan make:controller |
Create a new controller |
php artisan route:list |
View registered routes |
🤔 FAQs
❓ Is Laravel 12 stable?
Yes, Laravel 12 is the latest stable release with cutting-edge features and improvements.
❓ Can I upgrade from Laravel 11 to 12?
Yes, but it's recommended to follow the official upgrade guide to avoid breaking changes.
❓ Do I need Node.js?
Only if you're using Laravel Mix, Breeze, or building a frontend with Vue/React.