PHPackages                             laralgato/request-object - 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. laralgato/request-object

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

laralgato/request-object
========================

Simple way to convert your request data to an object.

1.1.0(9mo ago)06MITPHPPHP ^8.2

Since Jul 10Pushed 9mo agoCompare

[ Source](https://github.com/laralgato/request-object)[ Packagist](https://packagist.org/packages/laralgato/request-object)[ RSS](/packages/laralgato-request-object/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Request Object
==============

[](#request-object)

[![Latest Stable Version](https://camo.githubusercontent.com/25fa9e2badd6f3a7299435efaaa20fd2422a42adf7a07fca4fdf56ffea3030df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6172616c6761746f2f726571756573742d6f626a6563742e737667)](https://packagist.org/packages/laralgato/request-object)[![License](https://camo.githubusercontent.com/35ac24a1f3b6456ba0d4984c3c7a01a851bc3f10980f35af06db3c906732976e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6172616c6761746f2f726571756573742d6f626a6563742e737667)](LICENSE)

Simple way to convert your request data to an object.

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

[](#installation)

Install via Composer:

```
composer require laralgato/request-object
```

Usage
-----

[](#usage)

After installing the package, you can simply add a trait and an attribute to your Request. The Attribute accepts the object that you want as a result of the toObject method.

```
use Laragato\RequestObject\Attributes\FormObject;
use Laragato\RequestObject\Traits\useObjectRequest;

#[FormObject(MyObject::class)]
class TestRequest extends FormRequest
{
    use useObjectRequest;
    ...
}
```

### Creating the object with constructor :

[](#creating-the-object-with-constructor-)

In your controller you can simply use:

```
class TestController extends Controller
{
    public function __invoke(TestRequest $request)
    {
        $request->toObject();
    }
}
```

This line will perform the validation and return the object giving in the request. This is perfect for creating DTOs.

### Creating Models object

[](#creating-models-object)

If you want the result to be a Model or an object that requires the properties to be set one by one, you can use the toModel method:

```
class TestController extends Controller
{
    public function __invoke(TestRequest $request)
    {
        $request->toModel();
    }
}
```

This way you can simply call `->save()` on your model

```
$model = $request->toModel();
$model->save();
```

In case you want to update the model with `->save()`, you can add `update: true` to the Attribute. That will return copy of the model passed in the request with updated properties.

```
#[FormObject(MyObject::class, update: true)]
```

Then simply do

```
$model = $request->toModel();
$model->save();
```

To update the model.

Enjoy :)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance56

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

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 ~19 days

Total

2

Last Release

293d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9bc4c5444bffcc9ec7d17e054c6257098c7aefe4fc985fc0dabd6ace8d6fc62b?d=identicon)[SaadSebai](/maintainers/SaadSebai)

---

Top Contributors

[![SaadSebai](https://avatars.githubusercontent.com/u/76094750?v=4)](https://github.com/SaadSebai "SaadSebai (5 commits)")

---

Tags

laravellaragatorequest-objectrequest dto

### Embed Badge

![Health badge](/badges/laralgato-request-object/health.svg)

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

###  Alternatives

[highideas/laravel-users-online

This package will provide an online users management.

203113.2k1](/packages/highideas-laravel-users-online)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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