PHPackages                             lorisleiva/request-controller - 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. lorisleiva/request-controller

ActiveLibrary

lorisleiva/request-controller
=============================

FormRequest and InvokableController just had a baby

v0.1.1(5y ago)27643MITPHPPHP ^7.3|^7.4|^8.0CI failing

Since Nov 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lorisleiva/request-controller)[ Packagist](https://packagist.org/packages/lorisleiva/request-controller)[ Docs](https://github.com/lorisleiva/request-controller)[ GitHub Sponsors](https://github.com/sponsors/lorisleiva)[ RSS](/packages/lorisleiva-request-controller/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Use FormRequests as invokable controllers
=========================================

[](#use-formrequests-as-invokable-controllers)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4b9f0d32c03f4ab1e88455dba726a21849b138e4a7a182343400eb5f44e61bf6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f7269736c656976612f726571756573742d636f6e74726f6c6c65722e737667)](https://packagist.org/packages/lorisleiva/request-controller)[![GitHub Tests Action Status](https://camo.githubusercontent.com/403fd5cfdb1e2fc3dbce2a4ee21eafca8e654a91bdada37e503f845b33e9b9ac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6c6f7269736c656976612f726571756573742d636f6e74726f6c6c65722f54657374733f6c6162656c3d7465737473)](https://github.com/lorisleiva/request-controller/actions?query=workflow%3ATests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ff2601eaca3a638c2f84e6186381f1d6011e4b92530dbc67da49c11e3f7e0dfc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f7269736c656976612f726571756573742d636f6e74726f6c6c65722e737667)](https://packagist.org/packages/lorisleiva/request-controller)

Aren't you tired of having to create a `FormRequest` class for almost every invokable `Controller` you create?

It turns out, [with a few tweaks](https://lorisleiva.com/if-formrequests-and-invokable-controllers-had-a-baby/), you can use a `FormRequest` class as a controller.

This package provides only one class: a `RequestController` class that extends the `FormRequest` class we all know and adapt it slightly so it works as an invokable `Controller`.

Installation
------------

[](#installation)

```
composer require lorisleiva/request-controller
```

Usage
-----

[](#usage)

```
class MyController extends RequestController
{
    public function middleware()
    {
        return [];
    }

    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [];
    }

    public function __invoke()
    {
        // ...
    }
}
```

Note that the `middleware`, `authorize` and `rules` methods are all optional and default to the value displayed in the example.

Since `RequestController` extends `FormRequest`, you have access to all the methods you are used to, like:

- `$this->get($attribute)` — To access a request attribute.
- `$this->route($attribute)` — To access a route parameter.
- `$this->validated()` — To access the validated data.
- `$this->user()` — To access the user.
- Etc.

Similarly, you can override the same `FormRequest` methods you are used to, in order to customize the validation logic:

- `attributes()` — To provide user-friendly names to your attributes.
- `message()` — To customize your validation messages.
- `withValidator()` — To extends the current validator.
- `validator()` — To take full control over the validator created.
- Etc.

Enjoy! ✨

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

2009d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3642397?v=4)[Loris Leiva](/maintainers/lorisleiva)[@lorisleiva](https://github.com/lorisleiva)

---

Top Contributors

[![lorisleiva](https://avatars.githubusercontent.com/u/3642397?v=4)](https://github.com/lorisleiva "lorisleiva (23 commits)")

---

Tags

controllersform-requestlaravellorisleivarequest-controller

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lorisleiva-request-controller/health.svg)

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

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[timokoerber/laravel-one-time-operations

Run operations once after deployment - just like you do it with migrations!

6481.7M11](/packages/timokoerber-laravel-one-time-operations)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[illuminate/process

The Illuminate Process package.

44699.5k65](/packages/illuminate-process)

PHPackages © 2026

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