PHPackages                             jerry58321/api-transform - 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. [API Development](/categories/api)
4. /
5. jerry58321/api-transform

ActiveLibrary[API Development](/categories/api)

jerry58321/api-transform
========================

A Laravel API response transformation layer for reusable model and feature transforms.

v3.1.0(1mo ago)2282MITPHPPHP ^8.1CI passing

Since May 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Jerry58321/api-transform)[ Packagist](https://packagist.org/packages/jerry58321/api-transform)[ RSS](/packages/jerry58321-api-transform/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (12)Versions (20)Used By (0)

API Transform
=============

[](#api-transform)

[![Tests](https://github.com/Jerry58321/api-transform/actions/workflows/tests.yml/badge.svg)](https://github.com/Jerry58321/api-transform/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/3936f0f0d7fdf645ca290bc4eefa5c892c2bc05a28a1e09e36cc8621b050255b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6572727935383332312f6170692d7472616e73666f726d2e737667)](https://packagist.org/packages/jerry58321/api-transform)[![Total Downloads](https://camo.githubusercontent.com/b0e9cca8415548525f1607704b1fa107dfd40bc683364b3ad2cd1593d198414a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6572727935383332312f6170692d7472616e73666f726d2e737667)](https://packagist.org/packages/jerry58321/api-transform)[![License](https://camo.githubusercontent.com/fe4864bb738b1d0e501042f03ac74171f5fd5bc00c1c39e3cc9f1917089a1e64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6572727935383332312f6170692d7472616e73666f726d2e737667)](LICENSE)

API Transform is a Laravel package for building reusable API response transformers. It helps keep API output definitions close to the feature or model they represent, while allowing transforms to quote and compose one another.

Features
--------

[](#features)

- Define response schemas with small transform classes.
- Reuse model transforms inside feature transforms.
- Return consistent JSON responses from controllers.
- Support paginated resources and response metadata.
- Auto-discover the Laravel service provider through Composer.

Requirements
------------

[](#requirements)

- PHP 8.1 or later
- Laravel components 7.x, 8.x, 9.x, 10.x, 11.x, or 12.x

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

[](#installation)

```
composer require jerry58321/api-transform
```

Publish the package configuration when you need to customize the generated paths:

```
php artisan vendor:publish --provider="jerry58321\ApiTransform\TransformServiceProvider"
```

Concept
-------

[](#concept)

Transforms are usually grouped into two categories:

- `Models`: describe existing table or model schemas and can be reused by other transforms.
- `Features`: describe the response shape of each API feature and can compose model transforms or other feature transforms.

This keeps controller responses explicit while reducing duplicated response mapping code.

Basic Usage
-----------

[](#basic-usage)

```
use App\Models\LoginLog;
use App\Transforms\Models\LoginLogTransform;

class IndexController
{
    public function index()
    {
        $loginLog = LoginLog::with('user')->get();

        return LoginLogTransform::response(compact('loginLog'));
    }
}
```

```
use jerry58321\ApiTransform\Resources;
use jerry58321\ApiTransform\Transform;

class UserTransform extends Transform
{
    public function methodOutputKey(): array
    {
        return [
            'user' => false,
        ];
    }

    public function __user(Resources $resource): array
    {
        return [
            'account' => $resource->account,
            'name' => $resource->name,
        ];
    }
}
```

```
use jerry58321\ApiTransform\Resources;
use jerry58321\ApiTransform\Transform;

class LoginLogTransform extends Transform
{
    public function methodOutputKey(): array
    {
        return [
            'loginLog' => 'login_log',
        ];
    }

    public function __loginLog(Resources $resources): array
    {
        $user = UserTransform::quote(['user' => $resources->user]);

        return array_merge($user, [
            'ip' => $resources->ip,
            'login_at' => $resources->login_at,
        ]);
    }
}
```

Testing
-------

[](#testing)

```
composer install
composer test
```

Version Support
---------------

[](#version-support)

The current release line supports PHP 8.1+ and Laravel components 7.x through 12.x. Compatibility is tested against the maintained Laravel generations in GitHub Actions.

Security
--------

[](#security)

If you discover a security issue, please do not open a public issue with exploit details. Email the maintainer or open a minimal GitHub issue asking for a private coordination channel. See [SECURITY.md](SECURITY.md) for the current support policy.

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

[](#contributing)

Issues, compatibility reports, documentation fixes, and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for the local setup and pull request checklist.

Changelog
---------

[](#changelog)

Release notes are tracked in [CHANGELOG.md](CHANGELOG.md).

Maintenance Roadmap
-------------------

[](#maintenance-roadmap)

- Keep the package test suite running on supported PHP versions.
- Review Laravel compatibility as new framework versions are released.
- Improve examples for common response patterns such as pagination and metadata.
- Use Codex to assist with issue triage, pull request review, and release preparation.

License
-------

[](#license)

API Transform is open-sourced software licensed under the MIT license.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance94

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

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

Recently: every ~356 days

Total

19

Last Release

32d ago

Major Versions

v0.0.1 → v1.0.02022-05-11

v1.0.1 → v2.0.02022-05-31

v2.x-dev → v3.0.12023-08-06

PHP version history (2 changes)v0.0.1PHP ^8.0

v3.0.1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9935027189df6f0eddf29a8b546d6360de41d46437d725281159274d1908eaa1?d=identicon)[Hubertwei](/maintainers/Hubertwei)

---

Top Contributors

[![Jerry58321](https://avatars.githubusercontent.com/u/42406200?v=4)](https://github.com/Jerry58321 "Jerry58321 (62 commits)")

---

Tags

apicomposer-packagelaravelphptransformerresponseapilaraveltransformtransformer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jerry58321-api-transform/health.svg)

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

###  Alternatives

[flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

8911.6M5](/packages/flugger-laravel-responder)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725172.4k14](/packages/tallstackui-tallstackui)[nilportugues/laravel5-json-api

Laravel 5 JSON API Transformer Package

31232.5k1](/packages/nilportugues-laravel5-json-api)[dragon-code/laravel-json-response

Automatically always return a response in JSON format

1119.1k1](/packages/dragon-code-laravel-json-response)[nilportugues/laravel5-json-api-dingo

Laravel5 JSONAPI and Dingo together to build APIs fast

311.5k](/packages/nilportugues-laravel5-json-api-dingo)[nilportugues/laravel5-haljson

Laravel 5 HAL+JSON API Transformer Package

151.0k](/packages/nilportugues-laravel5-haljson)

PHPackages © 2026

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