stealthpro / lumen-form-request
Form requests for Lumen Micro Framework, ported from Laravel Framework.
Installs: 46
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.1.3
- illuminate/contracts: 5.6 - 5.8|^6.0|^7.0
- illuminate/http: 5.6 - 5.8|^6.0|^7.0
- illuminate/support: 5.6 - 5.8|^6.0|^7.0
- illuminate/validation: 5.6 - 5.8|^6.0|^7.0
- laravel/lumen-framework: 5.6 - 5.8|^6.0|^7.0
This package is auto-updated.
Last update: 2024-11-22 23:05:23 UTC
README
Form requests for Lumen Micro Framework, ported from Laravel Framework.
Support Lumen versions: 5.6+, 6.0+, 7.0+
Installation
- Install as composer package
composer require stealthpro/lumen-form-request
- Open your bootstrap/app.php and register as service provider
$app->register(Stealthpro\LumenFormRequest\Providers\FormRequestServiceProvider::class);
Usage
Refer to the official laravel documentation about form request usage
https://laravel.com/docs/master/validation#form-request-validation
Example Request
<?php namespace App\Http\Requests; use Stealthpro\LumenFormRequest\Http\FormRequest; class PostRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize(): bool { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'title' => [ 'required', 'string', 'max:255', 'unique:posts,title', ], 'description' => 'required|string', ]; } }
Usage in Controller
<?php namespace App\Http\Controllers; use App\Http\Requests\PostRequest; use App\Http\Controllers\Controller; class UsersController extends Controller { /** * Store a new user. * * @param PostRequest $request * @return Response */ public function store(PostRequest $request) { // store user } }