PHPackages                             anik/form-request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. anik/form-request

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

anik/form-request
=================

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

v5.0(2y ago)50373.4k↑11.6%24[1 PRs](https://github.com/ssi-anik/form-request/pulls)3MITPHPPHP ^7.2|^8.0

Since Aug 25Pushed 2y ago2 watchersCompare

[ Source](https://github.com/ssi-anik/form-request)[ Packagist](https://packagist.org/packages/anik/form-request)[ RSS](/packages/anik-form-request/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (15)Used By (3)

Form-Request [![codecov](https://camo.githubusercontent.com/5a5c0beb1a22bec7ece6866dd142bc47d2cd6bd1050807f784da9b7a0d71206a/68747470733a2f2f636f6465636f762e696f2f67682f7373692d616e696b2f666f726d2d726571756573742f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d31503537373353305359)](https://codecov.io/gh/ssi-anik/form-request)[![Total Downloads](https://camo.githubusercontent.com/25df9883ebe18c4f9f13d2181e3fd7bee0384f0c3d51d532d24f2ff044a53788/68747470733a2f2f706f7365722e707567782e6f72672f616e696b2f666f726d2d726571756573742f646f776e6c6f616473)](//packagist.org/packages/anik/form-request)[![Latest Stable Version](https://camo.githubusercontent.com/55a71df7e459e7802f5c90f80258156d99a901e873826ae229f514835823573e/68747470733a2f2f706f7365722e707567782e6f72672f616e696b2f666f726d2d726571756573742f76)](//packagist.org/packages/anik/form-request)
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#form-request)

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.

### Installation

[](#installation)

1. Install the package by running `composer require anik/form-request` from your terminal being in the project directory.
2. Register `\Anik\Form\FormRequestServiceProvider::class` to your `bootstrap/app.php` as a provider.

```
// bootstrap/app.php
$app->register(\Anik\Form\FormRequestServiceProvider::class);
```

### How to use?

[](#how-to-use)

- Create a class that extends `Anik\Form\FormRequest` class.
- You must override `rules` method of the `Anik\Form\FormRequest` class. Define your validation rules in it. Must return an **array**.
- You can define validation **messages** by overriding `messages` method. Default is `[]`.
- You can define custom pretty **attribute** names by overriding `attributes` method. Default is `[]`.
- You can override `authorize` method to define the authorization logic if the client is authorized to submit the form. Must return a boolean value. Default is `true`. When returning `false`, it'll raise `\Illuminate\Auth\Access\AuthorizationException` exception.
- If the validation fails, it will throw `Illuminate\Validation\ValidationException`.
    - By default, it returns response in `{"message": "The given data was invalid.", "errors": []}` format with status code `422`. Handle the exception in `app/Exceptions/Handler.php`'s `render` method if you want to modify the response.
    - Override the `statusCode` method to return the status of your choice. Must return `int`. Default is `422`.
    - Override the `errorMessage` method to return the message of your choice. Must return `string`. Default is `The given data was invalid.`
    - Override the `errorResponse` method to return response of your choice when the validation fails. Must return either of type `\Symfony\Component\HttpFoundation\Response` or `null`.
- Now you can inject your **Request** class through the method injections. All the methods of `Laravel\Lumen\Http\Request` class is available in your request class.
- The `FormRequest::validated()` method will return the validated data when the validation passes.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity49

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 96.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Recently: every ~208 days

Total

13

Last Release

1027d ago

Major Versions

v1.0 → v2.02017-08-27

v2.0 → v3.02020-02-20

v3.3 → v4.02021-04-11

v4.5 → v5.02023-07-26

PHP version history (3 changes)v1.0PHP &gt;=5.6

v4.0PHP ^7.3|^8.0

v4.1PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7180f132fd7bfbbec2083528838f87996e01a6165ef50e58e2f3fcfccda1a834?d=identicon)[ssi-anik](/maintainers/ssi-anik)

---

Top Contributors

[![ssi-anik](https://avatars.githubusercontent.com/u/2676602?v=4)](https://github.com/ssi-anik "ssi-anik (29 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

form-request-validationform-validationlumenlumen-packagephpvalidationvalidationlumenform-request

### Embed Badge

![Health badge](/badges/anik-form-request/health.svg)

```
[![Health](https://phpackages.com/badges/anik-form-request/health.svg)](https://phpackages.com/packages/anik-form-request)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k35.7M107](/packages/propaganistas-laravel-phone)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[pearl/lumen-request-validate

Lumen doesn't have form request validator seperatly. This package helps developers to segregate the validation layer from the controller to a separate dedicated class

45390.3k2](/packages/pearl-lumen-request-validate)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
