LaravelPackages.net
Acme Inc.
Toggle sidebar
lextira/laravel-formrequest-singleton

Use Laravel's excellent FormRequest as Singleton.

4.225
2
v1.1.0
About lextira/laravel-formrequest-singleton

lextira/laravel-formrequest-singleton is a Laravel package for use laravel's excellent formrequest as singleton.. It currently has 2 GitHub stars and 4.225 downloads on Packagist (latest version v1.1.0). Install it with composer require lextira/laravel-formrequest-singleton. Discover more Laravel packages by lextira or browse all Laravel packages to compare alternatives.

Last updated

laravel-formrequest-singleton

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.

Star History Chart