Form request is a package for Lumen that lets developer validate form requests like Laravel does.

v3.1 2020-05-10 20:18 UTC

This package is auto-updated.

Last update: 2020-06-10 20:27:49 UTC


A package that helps developer to segregate the validation logic from controller to a separate dedicated class. Lumen doesn't have any FormRequest class like Laravel. This will let you do that.


  1. First of all, you will need composer installed. By running composer require anik/form-request from your terminal will install the package inside your project.
  2. Register Anik\Form\FormRequestServiceProvider to your bootstrap/app.php as a provider

How to use?

  1. Create a class that extends Anik\Form\FormRequest
  2. Override rule method from FormRequest class. Define your validation rules inside that method.
  3. You can define your messages by overriding messages method.
  4. authorize method is also available to guard the request. Return true or false from this method. This will raise Unauthorized exception.
  5. If the validation fails, it will throw exception of Anik\Form\ValidationException class. Handle it on your app/Exception/Handle.php file. getResponse method returns the messages.
  6. Now you can use your Request class in method injections. All the methods from Illuminate\Http\Request class is available.