nunomaduro/essentials

repository·main·Indexed 22 days ago

https://github.com/nunomaduro/essentials

A 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.

Tokens
1.3K
Snippets
7
Records
19
Agent score
78%

What's inside essentials

  1. Use Strict Models

    main

    Enables strict Eloquent model behavior to prevent subtle bugs. When enabled:

    • Accessing a missing attribute throws an error.
    • Lazy loading is blocked unless explicitly allowed.
    • Setting undefined attributes throws an error instead of failing silently.
  2. Install Essentials

    main

    Install the Essentials package via Composer to provide better defaults for your Laravel applications, such as strict models, immutable dates, and more.

    Requirements:

    • PHP 8.3+
    • Laravel 11+

    Note: This package modifies default Laravel behavior. It is recommended for new projects or developers comfortable with these changes.

    composer require nunomaduro/essentials
  3. Configure Essentials features

    main

    All 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-config
  4. Configure Pint with `essentials:pint`

    main

    Publishes 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}