Download the PHP package jand3v/laravel-opinionated-essentials without Composer

On this page you can find all versions of the php package jand3v/laravel-opinionated-essentials. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-opinionated-essentials

Laravel Opinionated Essentials

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

Installation

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

Configuration

Publish the config file to adjust or disable individual defaults:

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

Opinionated Defaults

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

Behavior Config key Env variable Default
Eloquent 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

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

Immutable Dates

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

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:

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

Prohibit Destructive Commands (production only)

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


Generators

make:action

Creates a new Action class in app/Actions:

Generates app/Actions/PlaceOrderAction.php:

The Action suffix is added automatically. Passing PlaceOrderAction produces the same result — no double suffix.

--dto option

Pass --dto to generate an accompanying DTO and wire it into execute():

Generates both app/Actions/PlaceOrderAction.php and app/DTOs/PlaceOrderData.php:


make:dto

Creates a standalone DTO in app/DTOs without an Action:

Generates app/DTOs/PlaceOrderData.php (same structure as above). The Data suffix is added automatically — passing PlaceOrderData produces the same result.


DTOs and MapsFromArray

Every generated DTO uses the MapsFromArray trait, which maps an array (e.g. from $request->validated()) to constructor properties.

Defining a DTO

Creating instances

From a controller with a validated form request:

Or from any array:

Mapping resolution order

For each constructor parameter, the trait resolves the value in this order:

  1. #[MapFrom('key')] — explicit array key (highest priority).
  2. Exact camelCase name — e.g. customerName matches array key customerName.
  3. snake_case fallback — e.g. customerName also matches customer_name.
  4. Default value or nullable — uses the parameter's default, or null if nullable.
  5. InvalidArgumentException — thrown when a required key is missing.

Testing

License

The MIT License (MIT). See LICENSE for details.


All versions of laravel-opinionated-essentials with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jand3v/laravel-opinionated-essentials contains the following files

Loading the files please wait ...