lextira / laravel-formrequest-singleton
Use Laravel's excellent FormRequest as Singleton.
Installs: 2 391
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.0|^8.0|^8.1|^8.2
- laravel/framework: ^7.0|^8.0|^9.0|^10.0|^11.0
This package is auto-updated.
Last update: 2024-10-22 12:06:15 UTC
README
Use Laravel's excellent FormRequest as Singleton
Installation
- run
composer require lextira/laravel-formrequest-singleton
- open
config/app.php
in your project - replace
Illuminate\Foundation\Providers\FoundationServiceProvider::class
withLextira\FormRequestSingleton\FoundationServiceProvider::class
- done!
Usage
All classes, which extend Illuminate\Foundation\Http\FormRequest
are now instantiated as singleton.
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.