Laravel Essentials: Supercharge Your Laravel Development With Better Defaults
Published on June 7, 2025 by Dinesh Uprety

Introduction
Laravel is already a powerful and developer-friendly PHP framework, but what if you could make it even better with sensible defaults, stricter models, and automated optimizations? That's where Nuno Maduro's Essentials comes in.
This package enhances Laravel with strict mode for Eloquent models, auto-eager loading, immutable dates, and more, helping developers avoid common pitfalls while improving performance and security.
Built for Laravel 11+ and PHP 8.3+, Essentials is designed for modern Laravel applications, enforcing best practices while keeping things flexible.
Key Features & Benefits
✅ 1. Strict Models (No More Silent Failures!)
By default, Laravel silently ignores undefined model attributes and lazy-loaded relationships. Essentials changes this by:
- Throwing exceptions when accessing undefined attributes
- Blocking lazy loading (unless explicitly allowed)
- Preventing invalid assignments
Why? Fewer hidden bugs and more predictable model behavior.
// Throws an exception if 'non_existent_column' doesn't exist$user->non_existent_column;
⚡ 2. Auto Eager Loading (Bye, N+1 Queries!)
Forgets to add with()
? Essentials automatically eager loads relationships defined in $with
, reducing N+1
issues.
class User extends Model{ protected $with = ['posts']; // Always eager-loaded}
🕒 3. Immutable Dates (No More Surprises!)
Replaces Laravel's mutable Carbon
dates with CarbonImmutable
, preventing accidental date mutations.
$user->created_at->addDay(); // Returns a new instance instead of modifying
🔒 4. Force HTTPS (Security First!)
Ensures all generated URLs use HTTPS, improving security by default.
Internally package uses URL::forceHttps()
to enforce secure URLs in production.
<?php use Illuminate\Support\Facades\URL;use Illuminate\Support\Facades\App; private function configureUrl(): void{ URL::forceHttps(App::isProduction());}
🛑 5. Safe Console (Avoid Production Disasters!)
Blocks dangerous Artisan commands (like migrate:fresh) in production.
// Prevents accidental `php artisan migrate:fresh` in production
Much more features are available, including visit Nuno Maduro's Essentials.
Artisan Commands for Better Workflow
🏗️ make:action
(Clean Business Logic)
Generates single-responsibility action classes (great for moving logic out of controllers).
php artisan make:action CreateUserAction
Output:
final readonly class CreateUserAction{ public function handle(): void { DB::transaction(function (): void { // Business logic here }); }}
🎨 essentials:pint
(Stricter Code Standards)
Enhances Laravel Pint with stricter rules:
- Strict types (
declare(strict_types=1)
) - Final classes by default
- Strict comparisons (
===
instead of==
)
php artisan essentials:pint --force
🔄 essentials:rector
(Automated Refactoring)
Applies PHP modernization rules:
- Dead code removal
- Type declarations
- Early returns
php artisan essentials:rector
Installation & Setup
-
Require via Composer (Laravel 11+ & PHP 8.3+ required):
composer require nunomaduro/essentials:^0.1 -
Publish config (optional, to customize features):
php artisan vendor:publish --tag=essentials-stubs -
Enable/disable features in
config/essentials.php
:return [ShouldBeStrict::class => true, // Strict modelsUnguard::class => false, // Disable mass assignment protection?// ...];
When Should You Use Essentials?
- ✅ New Laravel projects – Start with best practices from day one
- ✅ Strict mode lovers – Prevents silent failures in models
- ✅ Performance-focused apps – Auto eager-loading & prefetching help
- ✅ Teams enforcing standards – Pint & Rector improve code quality
⚠️ Not recommended for legacy apps (unless you're ready for breaking changes)
Conclusion
Laravel Essentials is a game-changer for modern Laravel development, providing sensible defaults and automated optimizations that make your applications more robust, secure, and performant. By enforcing strict models, auto eager loading, immutable dates, and more, Essentials helps you avoid common pitfalls while keeping your code clean and maintainable.

Senior Software Engineer • Writer @ Laranepal • PHP, Laravel, Livewire, TailwindCSS & VueJS • CEO @ Laranepal & Founder @ laracodesnap