Use Optional Unguarded Models
main$fillable on every model.repository·main·Indexed 22 days ago
https://github.com/nunomaduro/essentialsA set of 'better defaults' for Laravel 11+ applications (PHP 8.3+) designed to enhance developer experience and stability. Features include strict Eloquent model behavior, CarbonImmutable dates, forced HTTPS, and production safety nets for Artisan commands. It provides utility commands like make:action for class generation, and essentials:pint and essentials:rector to publish opinionated configurations for Laravel Pint and Rector.
$fillable on every model.migrate:fresh.Sleep Facade to be faked, preventing actual delays during test execution.$with property, reducing N+1 query issues without requiring manual with() calls in every query.Enables strict Eloquent model behavior to prevent subtle bugs. When enabled:
CarbonImmutable across your entire application to prevent unexpected date mutations and improve predictability.Http Facade to prevent stray requests, ensuring that every HTTP call made during tests has been explicitly faked.https:// by default, securing application traffic.Install the Essentials package via Composer to provide better defaults for your Laravel applications, such as strict models, immutable dates, and more.
Requirements:
Note: This package modifies default Laravel behavior. It is recommended for new projects or developers comfortable with these changes.
composer require nunomaduro/essentialsAll features in Essentials are optional and can be enabled or disabled via the config/essentials.php configuration file. To modify the settings, first publish the configuration file using the vendor:publish command.
To disable a feature, set its corresponding class key to false in the configuration array.
php artisan vendor:publish --tag=essentials-configPublishes a specialized Laravel Pint configuration that enforces strict coding standards, including declare_strict_types, final_class, ordered_class_elements, and strict_comparison.
php artisan essentials:pint {--force} {--backup}