Conversation

Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!

Join the discussion and share your insights now!

Comments 0

Sharpen your coding skills—try JavaScript challenges on TOOLX now!

advertisement

Laravel 12 Structure and New Features – A Simple Guide

Laravel is one of the most popular PHP frameworks in the world, known for its elegant syntax, powerful tools, and developer-friendly features. ​Laravel 12 was officially released on February 24, 2025, as announced by Taylor Otwell at Laracon EU Amsterdam. With the release of Laravel 12, the framework continues to evolve and provide better structure, performance, and modern development tools.


Laravel 12 – Updated Folder Structure

Laravel 12 continues to follow the MVC (Model-View-Controller) pattern, but with some improvements in organization and code clarity. Let’s look at the major folders:

1. app/:

Contains your core application code. It includes:

  • Models – Business logic
  • Http – Controllers, Middleware, and Requests
  • Providers – Application service providers


2. bootstrap/:

  • Contains the app.php file that bootstraps the Laravel framework.
  • The cache/ folder stores framework-generated files.

3. config/:

All the configuration files for your app (e.g., database, cache, session, mail, etc.).


4. database/:

  • migrations/ – Handles version control for database schema
  • factories/ – Generate fake data for testing
  • seeders/ – Seed the database with initial data

5. public/:

The entry point for the app (index.php). Also contains your CSS, JS, and image assets.


6. resources/:

Holds your:

  • views/ – Blade templates
  • lang/ – Localization files
  • sass/ and js/ – Frontend assets (for Vite)

7. routes/:

Laravel 12 now supports even better route organization:

  • web.php – Web routes
  • api.php – API routes
  • console.php – Artisan commands
  • channels.php – Event broadcasting

8. storage/:

Stores logs, compiled views, file uploads, etc.


9. tests/:

For unit and feature testing.


10. vendor/:

Composer-managed packages.


New Features in Laravel 12

Laravel 12 introduces some cool new updates to make development faster, cleaner, and more modern. Here are the highlights:


1. Native Typed Enums Support:

Laravel 12 fully supports PHP 8.1+ enums. You can now use native enums in route model binding, form requests, and validation.

enum Status: string {
    case Active = 'active';
    case Inactive = 'inactive';
}


2. Pest as Default Testing Framework (Optional):

Laravel 12 supports Pest testing out of the box. You can now choose between Pest and PHPUnit when setting up your project.


3. Vite Improvements:

Laravel 12 enhances Vite support, especially for React, Vue, and TailwindCSS. The Vite config is cleaner and works smoothly with Laravel’s blade components.


4. Improved Route Security:

Now you can use attributes for route definitions and security:

#[Middleware(['auth'])]
Route::get('/dashboard', function () {
    return view('dashboard');
});


5. Artisan Command Upgrades:

Laravel 12 comes with smarter and more helpful Artisan command suggestions. You can even run commands directly in the browser using Laravel Herd or Valet.


6. Improved Job Batching and Queues:

Laravel 12 improves queue performance, job batching, and retry handling.


7. Cleaner Skeleton:

The default app skeleton is even more lightweight. Some unnecessary files are removed or separated better, making your application cleaner.


8. Better Type Safety:

Laravel 12 is stricter with types in route closures, controller methods, and service injection, helping prevent bugs early.


Final Thoughts

Laravel 12 is a solid release that focuses on developer experience, modern PHP features, and clean architecture. Whether you're building small websites or full-scale applications, Laravel 12 offers the tools and structure to help you code efficiently.


Laravel Laravel 12 Laravel 12 structure Laravel 12 new features PHP framework new laravel version Laravel 12 folder structure new features in laravel 12

advertisement