PHPackages                             pi-space/laravel-typed-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. pi-space/laravel-typed-request

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pi-space/laravel-typed-request
==============================

This is my package laravel-typed-request

v0.1.1(2y ago)73MITPHPPHP ^8.1

Since Aug 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Eyadhamza/Laravel-Typed-Request)[ Packagist](https://packagist.org/packages/pi-space/laravel-typed-request)[ Docs](https://github.com/pi-space/laravel-typed-request)[ RSS](/packages/pi-space-laravel-typed-request/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Typed Request
=====================

[](#laravel-typed-request)

[![Latest Version on Packagist](https://camo.githubusercontent.com/96186eddf14f92404ad3fbeba051a55739e66d18532ef214d90e98e4b22f92a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70692d73706163652f6c61726176656c2d74797065642d726571756573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pi-space/laravel-typed-request)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0d104c634711c1355b9c5aa4d9d29674234fe2f7e7cf75bda0c50a3a8924399e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70692d73706163652f6c61726176656c2d74797065642d726571756573742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/pi-space/laravel-typed-request/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/951788b24770e15559e8a04f112806ea51992ad51b02d7e06fe5b2dcf7f0828f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70692d73706163652f6c61726176656c2d74797065642d726571756573742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/pi-space/laravel-typed-request/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/620bbf4c90bf5f7df15924129d2a24f25681538dd56d601f2f150ea064637d69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70692d73706163652f6c61726176656c2d74797065642d726571756573742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pi-space/laravel-typed-request)

Laravel Typed Request is a package that enhances Laravel Form Request by introducing **Typed Classes and Attribute-based Validation Rules**.

This package provides a seamless way to create type-safe request classes, resulting in **improved code readability and enhanced IDE support**.

Features
--------

[](#features)

- Define Typed **Form Request classes** with **attribute-based validation rules**.
- Improved **code readability and maintainability**.
- Enhanced **IDE support for auto-completion and error checking**.

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

[](#installation)

You can install the package via composer:

```
composer require pi-space/laravel-typed-request
```

Usage
-----

[](#usage)

### Creating Typed Form Request Classes

[](#creating-typed-form-request-classes)

Laravel Typed Request simplifies the process of creating Typed Form Request classes. Let's take an example of creating an `ArticleRequest` class:

1. To create a typed request class, use the following Artisan command:

```
php artisan make:typed-request ArticleRequest
```

2. Open the generated `app/Http/Requests/ArticleRequest.php` file and update it as follows:

```
namespace PiSpace\LaravelTypedRequest\Tests\Requests;

use PiSpace\LaravelTypedRequest\Rules\Date;
use PiSpace\LaravelTypedRequest\Rules\MaxLength;
use PiSpace\LaravelTypedRequest\Rules\Nullable;
use PiSpace\LaravelTypedRequest\Rules\Required;
use PiSpace\LaravelTypedRequest\Rules\RequiredIfPatch;
use PiSpace\LaravelTypedRequest\Rules\StringValue;
use PiSpace\LaravelTypedRequest\TypedFormRequest;

class ArticleRequest extends TypedFormRequest
{
    #[Required, StringValue, MaxLength(255)]
    public readonly string $title;
    #[Required, StringValue, MaxLength(255)]
    public readonly string $body;
    #[Nullable, Date, RequiredIfPatch]
    public readonly ?string $published_at;
}
```

### Important Notes

[](#important-notes)

- The typed request class must extend the `PiSpace\LaravelTypedRequest\TypedFormRequest` class.
- All properties in the typed request class must be `readonly`.

### Available Rules

[](#available-rules)

- All available rules are located in the `PiSpace\LaravelTypedRequest\Rules` namespace. These rules are attribute-based and are similar to Laravel validation rules.
- You can create custom rules by extending the `PiSpace\LaravelTypedRequest\Rules\RuleAttribute` class.
- For example, the `RequiredIfPatch` rule checks if the request method is `PATCH`, making the attribute required only in that case.
- You have access to the request instance inside custom rule classes, allowing you to access request data.

### Creating a Custom Rule

[](#creating-a-custom-rule)

Let's create a custom rule called `RequiredIfPatch`:

1. To create the custom rule class, use the following Artisan command:

```
php artisan make:rule-attribute RequiredIfPatch
```

2. Open the generated `app/Rules/RequiredIfPatch.php` file and update it as follows:

```
#[Attribute]
class RequiredIfPatch extends RuleAttribute
{
    public function rule(): \Illuminate\Validation\Rules\RequiredIf
    {
        return Rule::requiredIf(fn() => $this->request->isMethod('PATCH'));
    }
}
```

Now you can use the `RequiredIfPatch` rule in your typed request classes.

Changelog
---------

[](#changelog)

For a detailed list of changes, see the [CHANGELOG](CHANGELOG.md).

Contributing
------------

[](#contributing)

We welcome contributions! Please see [CONTRIBUTING](CONTRIBUTING.md) for details on how to get involved.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover any security vulnerabilities, please review [our security policy](../../security/policy) on how to report them.

Credits
-------

[](#credits)

- [Eyad Hamza](https://github.com/Eyadhamza)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE.md) for more information.

```

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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

998d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d9cb15eabd6d8e7c3f899d9f176a8cf452db23c406ea7b3cdfcdaf3943ef0ba6?d=identicon)[EyadHamza](/maintainers/EyadHamza)

---

Top Contributors

[![Eyadhamza](https://avatars.githubusercontent.com/u/65258058?v=4)](https://github.com/Eyadhamza "Eyadhamza (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelPi-Spacelaravel-typed-request

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pi-space-laravel-typed-request/health.svg)

```
[![Health](https://phpackages.com/badges/pi-space-laravel-typed-request/health.svg)](https://phpackages.com/packages/pi-space-laravel-typed-request)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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