Whether you’re a seasoned Laravel developer or just getting started, setting up a Laravel 12 project the right way is crucial. In this guide, I’ll walk you through the complete process step-by-step — from installation to frontend setup.
🛠 Prerequisites
Before getting started, ensure your system has the following:
- ✅ PHP 8.2+
- ✅ Composer
- ✅ MySQL or PostgreSQL
- ✅ Node.js & NPM (for frontend assets)
- ✅ Optional: Laravel Valet, XAMPP, Docker, or Homestead
✅ Step 1: Install Laravel via Composer
Open your terminal and run:
composer create-project laravel/laravel my-laravel-app
Replace `my-laravel-app` with your preferred project folder name.
✅ Step 2: Set File Permissions (Linux/Mac)
Navigate into your project and update permissions:
cd my-laravel-app
chmod -R 775 storage bootstrap/cache
✅ Step 3: Configure Environment
Copy the example environment file:
cp .env.example .env
Generate the app key:
php artisan key:generate
Update your `.env` file with database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=secret
✅ Step 4: Run Laravel’s Built-In Server
Start the development server:
php artisan serve
Visit your app in the browser:
http://127.0.0.1:8000
✅ Step 5: Set Up Database & Migrations
Create your database manually or via CLI, then run:
php artisan migrate
✅ Step 6: Install Frontend Dependencies (Optional)
Laravel 12 uses Vite by default for frontend assets. To install:
npm install
npm run dev
For production:
npm run build
✅ Step 7: Git Ignore & Version Control
Initialize Git and commit your setup:
git init
git add .
git commit -m "Initial Laravel 12 setup"
Ensure the following are in your `.gitignore`:
/vendor
/node_modules
.env
✅ Step 8: Serve Using Valet (Optional for macOS)
If using Laravel Valet:
valet link
valet secure
Access your app via:
https://my-laravel-app.test
🧪 Step 9: Testing the Setup
Add this test route in `routes/web.php`:
Route::get('/test', fn () => 'Laravel 12 is working!');
Visit http://localhost:8000/test to verify it works.
🎯 Final Thoughts
You now have a fully functioning Laravel 12 project ready for development! From here, you can extend your setup with:
- 🔐 Authentication: Jetstream, Breeze
- 🔑 API tokens: Laravel Sanctum or Passport
- 🐳 Docker environment: Laravel Sail
📝 Conclusion
Setting up Laravel 12 doesn’t need to be overwhelming. Follow these steps to build a clean, maintainable foundation for your next web application.
If you found this helpful, leave a 💚 or comment below.
👉 Want more tutorials? Click here to explore more Laravel content
Social Plugin