Essentials is a package created by Nuno Maduro that provides better defaults for your Laravel applications. It includes strict models, automatically eagerly loaded relationships, immutable dates, and more.
Main Features
- Enforce Strict Models: This improves how Eloquent handles undefined attributes, lazy loading, and invalid assignments.
- Eager Loading: Automatically eager loads relationships defined in the model's
$withproperty. - Optional Unguarded Models: Disables Laravel's mass assignment protection globally (opt-in).
- Immutable Dates: Uses
CarbonImmutableinstead of mutable date objects across your app - Force HTTPS: Ensures all generated URLs to use HTTPS
- Safe Console: Blocks potentially destructive Artisan commands in production (e.g.,
migrate:fresh). - Asset Prefetching: Configures Laravel Vite to preload assets more aggressively.
- Prevent Stray Requests: Configures the Laravel HTTP facade to prevent stray requests from being sent.
- Fake Sleep: Configures Laravel Sleep Facade to be faked.
- Additional Artisan commands: To generate Action classes with
make:actionand also configure Pint and Rector with some recommended defaults usingessentials:pintandessentials:rector. - And more features are to come.
Although this package includes several reasonable defaults, all features are configurable through the config/essentials.php configuration file.
Note: Nuno recommends using this package only in new projects or when you are comfortable with the changes it introduces, as it modifies Laravel's default behavior.
To install this package, you can run the following commands:
composer require nunomaduro/essentialsphp artisan vendor:publish --tag=essentials-stubs
Learn more about this package and view the source code on GitHub.