soufiene-slimi / lumen-form-requests
Missing form requests functionality for lumen, ported from laravel framework.
Installs: 93
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.1.3
- illuminate/contracts: ^8.0|^7.0|^6.0
- illuminate/http: ^8.0|^7.0|^6.0
- illuminate/support: ^8.0|^7.0|^6.0
- illuminate/validation: ^8.0|^7.0|^6.0
- laravel/lumen-framework: ^8.0|^7.0|^6.0
This package is auto-updated.
Last update: 2024-11-19 18:56:59 UTC
README
Missing form requests functionality for lumen, ported from laravel framework.
Installation
- Install as composer package
composer require soufiene-slimi/lumen-form-requests
- Open your bootstrap/app.php and register as service provider
$app->register(Slimi\Form\Providers\FormRequestServiceProvider::class);
Usage
Refer to the official laravel documentation about form request usage
https://laravel.com/docs/5.7/validation#form-request-validation
Example Request
<?php namespace App\Http\Requests; use Slimi\Microservice\Foundation\Http\Requests\Request; class CreateUserRequest extends Request { /** * 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 { $rules = [ 'email' => [ 'required', 'email', 'unique:users,email', ], 'password' => [ 'required', ], ]; } }
Usage in Controller
<?php namespace App\Http\Controllers; use App\Http\Requests\CreateUserRequest; use App\Http\Controllers\Controller; class UsersController extends Controller { /** * Store a new user. * * @param CreateUserRequest $request * @return Response */ public function store(CreateUserRequest $request) { // store user } }