PHPackages                             shetabit/transform-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. shetabit/transform-request

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

shetabit/transform-request
==========================

Transform laravel requests

v1.0(6y ago)17MITPHPPHP &gt;=7.2

Since Aug 27Pushed 6y ago2 watchersCompare

[ Source](https://github.com/shetabit/transform-request)[ Packagist](https://packagist.org/packages/shetabit/transform-request)[ Docs](https://github.com/shetabit/transform-request)[ RSS](/packages/shetabit-transform-request/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

 [![](resources/images/diagram.png?raw=true)](resources/images/diagram.png?raw=true)

Transform laravel requests
==========================

[](#transform-laravel-requests)

you can **normalize** or **change request data structure** with transformers.

> lets **normalize** our data in `transformers` and let `controllers` to be much more **cleaner** and **smaller**.

List of contents
----------------

[](#list-of-contents)

- [Install](#install)
- [How to use](#how-to-use)
    - [Create a new data transformer](#create-a-new-data-transformer)
    - [Transform requests](#transform-requests)
- [Change log](#change-log)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Install
-------

[](#install)

Via Composer

```
$ composer require shetabit/transform-request
```

How to use
----------

[](#how-to-use)

#### Create a new data transformer

[](#create-a-new-data-transformer)

> we use transformers to transform request data.

you can run the below command in your console in order to create a new data transformer named `TestTransformer`.

```
$ composer php artisan make:transformer TestTransformer
```

all transformers will be created in `App\Http\Transformers` path.

#### Transformer example:

[](#transformer-example)

in all transformers, the `transform` method will transform your data into your ideal one. for example we can write the below code in it:

```
namespace App\Http\Transformers;

use Shetabit\Transformer\Contracts\TransformerInterface;

class TestTransformer implements TransformerInterface
{
    /**
     * transform given data
     *
     * @param array $data
     * @return array
     */
    public function transform(array $data) : array {
        /*
            input data :
            [
                'n' => 'mahdi',
                'f' => 'khanzadi'
            ]

            transformed data:
            [
                'name' => 'mahdi',
                'family' => 'khanzadi',
                'username' => 'mahdikhanzadi'
            ]
        */

        return [
            'name' => $data['n'] ?? null,
            'family' => $data['f'] ?? null,
            'username' => ($data['n'] ?? null).($data['f'] ?? null)
        ];
    }
}
```

#### Transform requests

[](#transform-requests)

we can use a transformer to transform requests like the below:

```
namespace App\Http\Controllers;

use App\Http\Transformers\TestTransformer;
use Illuminate\Http\Request;

class TestController extends Controller
{
    public function __invoke(Request $request) {
        $data = $request->transform()->get(new TestTransformer());

        print_r($data)
    }
}
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mahdi khanzadi](https://github.com/khanzadimahdi)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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

Unknown

Total

1

Last Release

2456d ago

### Community

Maintainers

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

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

---

Top Contributors

[![roshedgostarandev1](https://avatars.githubusercontent.com/u/52368299?v=4)](https://github.com/roshedgostarandev1 "roshedgostarandev1 (8 commits)")

---

Tags

transform laravel requestsmodify laravel request key names

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/shetabit-transform-request/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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