| Package Data | |
|---|---|
| Maintainer Username: | mayoz | 
| Maintainer Contact: | srcnckr@gmail.com (Sercan Cakir) | 
| Package Create Date: | 2020-04-28 | 
| Package Last Update: | 2020-12-22 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-27 03:18:33 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 2,519 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 2 | 
| Total Watchers: | 1 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
Adopt the Laravel Form Request to Lumen framework.
You can install the package via composer:
composer require mayoz/lumen-form-request
Register the service provider in your boostrap/app.php configuration file:
$app->register(Illuminate\Foundation\Providers\FormRequestServiceProvider::class);
Let's continue the official Laravel's documantation.
If you want to format the verification messages, follow these steps:
Firstly import the ValidationException class:
use Illuminate\Validation\ValidationException;
Add (if need) the dontReport list:
/**
 * A list of the exception types that should not be reported.
 *
 * @var array
 */
protected $dontReport = [
    // ...
    ValidationException::class,
];
And finally update the render method:
/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Throwable  $exception
 * @return \Symfony\Component\HttpFoundation\Response
 *
 * @throws \Throwable
 */
public function render($request, Throwable $exception)
{
    if ($exception instanceof ValidationException) {
        return $this->convertValidationExceptionToResponse($exception, $request);
    }
    return parent::render($request, $exception);
}
/**
 * Create a response object from the given validation exception.
 *
 * @param  \Illuminate\Validation\ValidationException  $e
 * @param  \Illuminate\Http\Request  $request
 * @return \Symfony\Component\HttpFoundation\Response
 */
protected function convertValidationExceptionToResponse(ValidationException $e, $request)
{
    if ($e->response) {
        return $e->response;
    }
    return response()->json([
        'message' => $e->getMessage(),
        'errors' => $e->errors(),
    ], $e->status);
}
This package is licensed under The MIT License (MIT).