Skip to content

Step-by-Step Guide to Setting Up a Laravel 12 Project (2025)

Learn how to set up a Laravel project in 2025 with this easy step-by-step guide. From installation to configuration, follow best practices to start building modern, efficient web applications using Laravel 12.

Dasun Kalupahana 2 min read 2K views 0 comments

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.

🛠 Prerequisites

Before starting, make sure your system has:

  • 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 desired project folder name.


Step 2: Set File Permissions (Linux/Mac)
cd my-laravel-app
chmod -R 775 storage bootstrap/cache

Step 3: Configure Environment

Copy the example .env file and configure your environment:

cp .env.example .env

Generate the application key:

php artisan key:generate

Update your .env with DB 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

You can run the local server using:

php artisan serve

Visit: http://127.0.0.1:8000


Step 5: Setup Database & Migrate

Create a database manually or via CLI, then run:

php artisan migrate

This will set up the default tables.


Step 6: Install Frontend Dependencies (Optional)

If you’re using Laravel Vite (default since Laravel 9+), run:

npm install
npm run dev

For production assets:

npm run build

Step 7: Git Ignore & Version Control

Initialize Git (if not done):

git init
git add .
git commit -m "Initial Laravel 12 setup"

Ensure .env, node_modules, and vendor folders are in .gitignore.


Step 8: Serve Using Valet (Optional for macOS)
valet link
valet secure

Access via https://my-laravel-app.test


Step 9: Testing the Setup
// routes/web.php
Route::get('/test', fn () => 'Laravel 12 is working!');

Navigate to http://localhost:8000/test to see the message.


Final Thoughts

You now have a fully functioning Laravel 12 project ready for development. You can extend this setup with:

  • Authentication: php artisan make:auth (Jetstream/Breeze)
  • API: Laravel Sanctum or Passport
  • Docker: Laravel Sail
Conclusion

Setting up Laravel 12 doesn’t need to be overwhelming. Follow these steps and you’ll have a clean foundation for any kind of web application.

If you found this helpful, please leave a 💚 or comment below.

Let me know if you’d like a Markdown version, code formatting for Medium, or want to include extras like Sail, Docker, or Jetstream setup.

Free resources for this topic

Code snippets and fixes for this topic

Get one practical tip every week

New tutorials, fixes and free cheat sheets from DEV Talk, straight to your inbox. No spam, unsubscribe in one click.

Free download: Laravel interview questions (PDF)

Have a question about this post?

Ask the community: other developers and the author can answer.

Ask the community

Get notified about new articles

One click, no email needed. Turn it off anytime with the bell at the top.

Get new articles on your iPhone

Add DEV Talk to your Home Screen, open it, then tap the bell.

Rate this post
0.0
Share

Enjoying the content?

If this article helped you, you can support the author with a coffee. It keeps new posts coming.

Buy me a coffee (opens in a new tab)

Comments 0

Be kind. Comments with links are reviewed before they appear.

No comments yet

Be the first to share your thoughts.

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.