PHPackages                             nacoma/payloads - 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. nacoma/payloads

ActiveLibrary

nacoma/payloads
===============

A strong typed payload library for Laravel.

33[2 issues](https://github.com/Nacoma/Payloads/issues)PHP

Since Jul 12Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Nacoma/Payloads)[ Packagist](https://packagist.org/packages/nacoma/payloads)[ RSS](/packages/nacoma-payloads/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Payloads
========

[](#payloads)

[![tests](https://github.com/Nacoma/Payloads/actions/workflows/tests.yml/badge.svg)](https://github.com/Nacoma/Payloads/actions/workflows/tests.yml)[![codecov](https://camo.githubusercontent.com/4baa18aa958bf1b22c764f09cd56c603a979128e7eb8384d026150e410f6f5a8/68747470733a2f2f636f6465636f762e696f2f67682f4e61636f6d612f5061796c6f6164732f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4550455a3343484f475a)](https://codecov.io/gh/Nacoma/Payloads)

This is an MVP/POC.

Summary
-------

[](#summary)

Classes with the `#[Payload]` attribute can be resolved from the container and are hydrated automatically with data from the request payload. This enables strong type hints and intellisense for request bodies while decoupling the payload from the `Request`.

Validation
----------

[](#validation)

The optional validation provided by Payloads is a thin, strongly typed, wrapper around Laravel's built-in validation.

Hydration
---------

[](#hydration)

- [Class Instances](#instance)
- [Arrays &amp; Collections](#arrays--collections)
- [Eloquent Models](#models)

### Instance

[](#instance)

Create an instance of a class from request parameters:

```
use Nacoma\Payloads\Hydrators\Attributes\MakeInstance;

new class {
    #[MakeInstance]
    public SomeClass $someClass1;

    #[MakeInstance(SomeOtherConcrete::class)]
    public SomeClass $someClass2;
};
```

### Arrays &amp; Collections

[](#arrays--collections)

The `MakeList` plugin assumes that the type is either an `array` or some type of `collection` that takes an `array` of items as the constructor parameter.

```
use Nacoma\Payloads\Hydrators\Attributes\MakeList;
use Illuminate\Support\Collection;

new class {
    /**
     * @var SomeClass[]
     */
    #[MakeList(SomeClass::class)]
    public array $items1;

    #[MakeList(SomeClass::class)]
    public Collection $item2;
};
```

### Models

[](#models)

Fetch a model from the database using `FindModel`.

```
use Nacoma\Payloads\Hydrators\Attributes\FindModel;

new class {
    #[FindModel]
    public User $user;
};
```

More Featured Example
---------------------

[](#more-featured-example)

```
use Nacoma\Payloads\Hydrators\Attributes\FindModel;use YourApp\Models\Country;
use Nacoma\Payloads\Rules\Attributes as Rule;
use Nacoma\Payloads\Payload;
use Nacoma\Payloads\Transformers\Attributes as Transform;

#[Payload]
class UpdateUser {
    public function __construct(
        #[Rule\Required]
        public string $name,

        #[Rule\Required]
        #[Rule\Min(13)]
        #[Rule\Max(120)]
        public int $age,

        #[Rule\Required]
        #[Rule\Exists('countries', 'id')]
        #[Transform\Rename('country_id')]
        #[FindModel]
        public Country $country,
    ) {
      //
    }
}
```

```
class UserController extends Controller {
    public function update(User $user, UpdateUser $payload)
    {
        dump($payload->country->id);
    }
}
```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/11e33c71e59361305dacb0d214c4956981c8888b93a549d1877ef2a9122ad242?d=identicon)[Nacoma](/maintainers/Nacoma)

### Embed Badge

![Health badge](/badges/nacoma-payloads/health.svg)

```
[![Health](https://phpackages.com/badges/nacoma-payloads/health.svg)](https://phpackages.com/packages/nacoma-payloads)
```

PHPackages © 2026

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