Laravel 11 revolutionizes the framework with a dramatically simplified application structure. Fewer files, cleaner defaults, and modern PHP features. At ZIRA Software, Laravel 11 reduces boilerplate across all new projects.
New Application Structure
Laravel 10 Laravel 11
├── app/ ├── app/
│ ├── Console/ │ ├── Models/
│ │ └── Kernel.php │ ├── Providers/
│ ├── Exceptions/ │ │ └── AppServiceProvider.php
│ │ └── Handler.php │ └── Http/
│ ├── Http/ │ └── Controllers/
│ │ ├── Kernel.php ├── bootstrap/
│ │ └── Middleware/ │ └── app.php
│ ├── Models/ ├── routes/
│ └── Providers/ │ ├── web.php
│ ├── AppServiceProvider │ └── console.php
│ ├── AuthServiceProvider └── ...
│ ├── BroadcastService...
│ ├── EventServicePro...
│ └── RouteServicePro...
└── ...
Files removed: ~15 files
Installation
# New project
composer create-project laravel/laravel myapp
# Or with Laravel installer
laravel new myapp
Bootstrap Changes
// bootstrap/app.php - New unified configuration
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
\App\Http\Middleware\CustomMiddleware::class,
]);
$middleware->api(prepend: [
\App\Http\Middleware\EnsureTokenIsValid::class,
]);
})
->withExceptions(function (Exceptions $exceptions) {
$exceptions->report(function (Throwable $e) {
// Custom reporting
});
$exceptions->render(function (NotFoundHttpException $e) {
return response()->view('errors.404', [], 404);
});
})
->create();
Console Commands
// routes/console.php - No more Kernel.php
use Illuminate\Support\Facades\Schedule;
Schedule::command('app:daily-report')->daily();
Schedule::command('queue:prune-batches')->daily();
Schedule::job(new ProcessOrders)->hourly();
// Artisan commands
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
Per-Second Rate Limiting
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->throttleApi(
limiter: 'api',
perSecond: true, // New in Laravel 11
);
})
// Custom rate limiter
RateLimiter::for('api', function (Request $request) {
return Limit::perSecond(10)->by($request->user()?->id ?: $request->ip());
});
Simplified Middleware
// No more HTTP Kernel - configure in bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
// Global middleware
$middleware->use([
\Illuminate\Http\Middleware\TrustProxies::class,
]);
// Web middleware group
$middleware->web(append: [
\App\Http\Middleware\HandleInertiaRequests::class,
]);
// Middleware aliases
$middleware->alias([
'admin' => \App\Http\Middleware\EnsureUserIsAdmin::class,
]);
// Middleware priority
$middleware->priority([
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\Auth\Middleware\Authenticate::class,
]);
})
Model Casts as Methods
// Laravel 11 - Casts as method
class User extends Model
{
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'options' => AsCollection::class,
'settings' => AsEnumCollection::class.':'.UserSetting::class,
];
}
}
Health Check Endpoint
// Built-in health check at /up
->withRouting(
web: __DIR__.'/../routes/web.php',
health: '/up', // Returns 200 OK
)
// Custom health check
Route::get('/health', function () {
return response()->json([
'status' => 'healthy',
'database' => DB::connection()->getPdo() ? 'connected' : 'disconnected',
'cache' => Cache::store()->getStore() ? 'connected' : 'disconnected',
]);
});
Dumpable Trait
use Illuminate\Support\Traits\Dumpable;
class User extends Model
{
use Dumpable;
}
// Chain dump in queries
User::query()
->where('active', true)
->dd() // Dump and die
->get();
$user->dump()->save(); // Dump and continue
Migration from Laravel 10
# Step 1: Update composer.json
"laravel/framework": "^11.0"
# Step 2: Run upgrade
composer update
# Step 3: Restructure (optional but recommended)
# Move Kernel logic to bootstrap/app.php
# Remove unused service providers
# Consolidate exception handling
// Keep compatibility - files still work if present
// Laravel 11 checks for Kernel files and uses them if they exist
Conclusion
Laravel 11's streamlined structure reduces cognitive load and boilerplate. Fewer files means faster onboarding and cleaner projects. The upgrade path remains smooth for existing applications.
Planning Laravel 11 upgrade? Contact ZIRA Software for migration assistance.