PHPackages                             jand3v/laravel-opinionated-essentials - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. jand3v/laravel-opinionated-essentials

ActiveLibrary[Framework](/categories/framework)

jand3v/laravel-opinionated-essentials
=====================================

Opinionated essentials for Laravel applications.

v1.0.1(1mo ago)02MITPHPPHP ^8.3CI passing

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/jand3v/laravel-opionated-essentials)[ Packagist](https://packagist.org/packages/jand3v/laravel-opinionated-essentials)[ RSS](/packages/jand3v-laravel-opinionated-essentials/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Laravel Opinionated Essentials
==============================

[](#laravel-opinionated-essentials)

Opinionated essentials for Laravel applications. Applies sensible framework defaults automatically and provides generators for common patterns.

Installation
------------

[](#installation)

```
composer require jand3v/laravel-opinionated-essentials
```

The service provider is auto-discovered — no manual registration required.

Configuration
-------------

[](#configuration)

Publish the config file to adjust or disable individual defaults:

```
php artisan vendor:publish --tag=opinionated-essentials-config
```

This creates `config/opinionated-essentials.php` in your application. Every default can be toggled via environment variables.

### Opinionated Defaults

[](#opinionated-defaults)

The following behaviors are applied automatically when the package is installed:

BehaviorConfig keyEnv variableDefaultEloquent lazy-loading prevention (non-production)`models.prevent_lazy_loading``OPINIONATED_ESSENTIALS_PREVENT_LAZY_LOADING``true`Carbon immutable dates`dates.immutable``OPINIONATED_ESSENTIALS_IMMUTABLE_DATES``true`Secure password rules in production`passwords.secure``OPINIONATED_ESSENTIALS_SECURE_PASSWORDS``true`Prohibit destructive DB commands in production`database.prevent-destruction``OPINIONATED_ESSENTIALS_PREVENT_DB_DESTRUCTION``true`To disable a default, set the env variable to `false` or update `config/opinionated-essentials.php`.

#### Lazy Loading Prevention

[](#lazy-loading-prevention)

Outside of production, accessing an unloaded Eloquent relationship throws a `LazyLoadingViolationException`, forcing eager loading and preventing N+1 queries:

```
// ✗ Throws LazyLoadingViolationException outside production
$post->comments;

// ✓ Always safe
Post::with('comments')->get();
```

#### Immutable Dates

[](#immutable-dates)

All date instances returned by Eloquent are `CarbonImmutable`, preventing accidental mutation:

```
$user->created_at->addDay(); // returns a new instance, original unchanged
```

#### Secure Passwords (production only)

[](#secure-passwords-production-only)

In production, `Password::defaults()` requires a minimum of 12 characters, mixed case, letters, numbers, symbols, and checks the password against the HaveIBeenPwned database:

```
// Use the default password rule in your form requests
'password' => ['required', Password::default()],
```

In non-production environments `Password::default()` returns `null` (no extra constraints), making registration easy during development.

#### Prohibit Destructive Commands (production only)

[](#prohibit-destructive-commands-production-only)

`DB::prohibitDestructiveCommands(true)` is called in production, preventing `migrate:fresh`, `migrate:reset`, and `db:wipe` from running accidentally.

---

Generators
----------

[](#generators)

### `make:action`

[](#makeaction)

Creates a new Action class in `app/Actions`:

```
php artisan make:action PlaceOrder
```

Generates `app/Actions/PlaceOrderAction.php`:

```
