Skip to content

Commit 0c3b86e

Browse files
committed
added README
1 parent 28189f2 commit 0c3b86e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
11
# laravel-formrequest-singleton
22
Use Laravel's excellent FormRequest as Singleton
3+
4+
## Installation
5+
6+
* run `composer require lextira/laravel-formrequest-singleton`
7+
* open `config/app.php` in your project
8+
* replace `Illuminate\Foundation\Providers\FoundationServiceProvider::class`
9+
with `Lextira\FormRequestSingleton\FoundationServiceProvider::class`
10+
* done!
11+
12+
## Usage
13+
14+
All classes, which extend `Illuminate\Foundation\Http\FormRequest` are now instantiated as singleton.
15+
16+
This brings the following benefits:
17+
* Changes done to the request by `prepareForValidation()` are applied only once,
18+
even if the FormRequest is used multiple times.
19+
* The request validation is run only once, therefore especially database queries run only once.

0 commit comments

Comments
 (0)