Before you start coding, properly setting up your Laravel 12 development environment is crucial. This guide covers every essential step, with clear explanations and commands, to get your Laravel project ready for development.
1. Install Prerequisites
What you need:
-
PHP 8.2 or later (Laravel 12 requires PHP 8.2 minimum)
-
Composer (dependency manager for PHP)
-
Database Server (MySQL, PostgreSQL, SQLite, or SQL Server — most common is MySQL/MariaDB)
-
Node.js & npm (for compiling CSS/JS assets with Vite)
Verify installations
Run the following commands in your terminal:
👉 If something is missing, install from the official sites:
2. Create a New Laravel 12 Project
Option 1: Using Composer
Option 2: Using Laravel Installer
If you have the Laravel installer installed globally:
Navigate into the project folder:
3. Configure Environment Variables (.env
file)
Laravel uses a .env
file for environment-specific configuration.
Copy the example file:
Update the .env
file:
📌 Notes:
-
APP_DEBUG=true
enables detailed error messages (development only). -
Ensure your database settings match your local configuration.
4. Generate Application Key
Run the following command to generate an application key:
This updates the APP_KEY
in your .env
file automatically.
5. Create a Database
Example (MySQL):
Make sure the name matches the DB_DATABASE
in your .env
file.
6. Run Database Migrations
Run Laravel’s default migrations:
This will create essential tables like users
, password_resets
, and more.
7. Set File Permissions (Linux/macOS Only)
Laravel requires write access to certain folders:
If your web server user is different:
(Windows users usually don’t need this step.)
8. Create a Storage Symlink
To make uploaded files accessible via the browser:
This links public/storage
→ storage/app/public
.
9. Install Node Modules & Compile Assets
Install Node.js dependencies:
Compile assets for development:
Compile for production (optimized and minified):
📌 Laravel 12 uses Vite (instead of Laravel Mix).
10. Run Laravel Development Server
Start the server:
Now open your browser and visit:
👉 You should see Laravel’s default welcome page 🎉
✅ Conclusion
You’ve now completed the pre-development setup for Laravel 12. Your environment is ready, your database is connected, and your project is fully configured. From here, you can begin building your Laravel 12 application with confidence. 🚀