lextira/laravel-formrequest-singleton

Use Laravel's excellent FormRequest as Singleton.

Maintainers

Package info

github.com/lextira/laravel-formrequest-singleton

pkg:composer/lextira/laravel-formrequest-singleton

Statistics

Installs: 3 956

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v1.1.0 2026-03-25 12:59 UTC

README

Use Laravel's excellent FormRequest as Scoped

Installation

  • run composer require lextira/laravel-formrequest-singleton
  • open config/app.php in your project
  • replace Illuminate\Foundation\Providers\FoundationServiceProvider::class
    with Lextira\FormRequestSingleton\FoundationServiceProvider::class
  • done!

Usage

All classes, which extend Illuminate\Foundation\Http\FormRequest are now instantiated as scoped.

This brings the following benefits:

  • Changes done to the request by prepareForValidation() are applied only once, even if the FormRequest is used multiple times.
  • The request validation is run only once, therefore especially database queries run only once.