PHPackages                             gwsn/transformer - 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. gwsn/transformer

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

gwsn/transformer
================

Data Transformer to Transform data from API response to arrays or objects

1.1.3(6y ago)09611MITPHPPHP &gt;=7.0

Since Mar 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/gwsn/transformer)[ Packagist](https://packagist.org/packages/gwsn/transformer)[ Docs](https://www.globalwebsystems.nl)[ RSS](/packages/gwsn-transformer/feed)WikiDiscussions master Synced 2w ago

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

Transformer Package
-------------------

[](#transformer-package)

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

[](#installation)

Require this package

```
composer require gwsn/transformer

```

Frameworks specific packages
----------------------------

[](#frameworks-specific-packages)

1. [Lumen/Laravel](https://github.com/gwsn/lumen-transformer)`composer require gwsn/lumen-transformer`
2. [Symfony](https://github.com/gwsn/symfony-transformer)`composer require gwsn/symfony-transformer`

Simple example
--------------

[](#simple-example)

Include the Transformer class:

`use Gwsn\Transformer\Transformer;`

In this use case we work only with arrays.

```
$source = [
    [
        'id'   => '1',
        'name' => 'Test 1',
        'type' => 'text',
        'text' => 'Some text written by Cicero that's used to fill spaces on.'
    ],
    [
        'id'   => '2',
        'name' => 'Test 2',
        'type' => 'short-text',
        'text' => 'The reason why it is difficult to understand is to draw attention away from the words on a page and to focus it on the design instead.'
    ],
    [
        'id'   => '3',
        'name' => 'Test 3',
        'type' => 'text',
        'text' => 'It's also useful for filling spaces where text should be because its words are about the same length as normal English writing.'
    ],
];

$mapping = [
    'guid' => 'id',
    'slug' => 'name',
    'type' => 'type',
    'text' => 'text',
];

$target = Transformer::run($source, Transformer::BuildMapping($mapping));

var_dump(json_encode($target));
output:

 [
     {
         guid: "1",
         slug: "Test Company mapper 1",
         type: "company",
         text: "asdasdfafa afad afads aadssafdf astext"
     },
     {
         guid: "2",
         slug: "Test Company mapper 2",
         type: "blog",
         text: "asdasdfafa afad afads aadssafdf astext"
     },
     {
         guid: "3",
         slug: "Test Company mapper 3",
         type: "company",
         text: "asdasdfafa afad afads aadssafdf astext"
     }
 ]

```

For the more advanced documentation about the usage you can find it here [documentation](https://github.com/gwsn/Transformer/tree/master/examples/usage.md)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

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

Recently: every ~94 days

Total

13

Last Release

2470d ago

### Community

Maintainers

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

---

Top Contributors

[![jnovermars](https://avatars.githubusercontent.com/u/4355811?v=4)](https://github.com/jnovermars "jnovermars (23 commits)")

---

Tags

mappingtransformerapi-response

### Embed Badge

![Health badge](/badges/gwsn-transformer/health.svg)

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

###  Alternatives

[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k11.7M155](/packages/cuyz-valinor)[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457451.1k4](/packages/cornford-googlmapper)[yzen.dev/plain-to-class

Class-transformer to transform your dataset into a structured object

162101.6k6](/packages/yzendev-plain-to-class)[ballen/distical

A distance (Lat/Long) calculation library for PHP

40194.3k2](/packages/ballen-distical)[selective/transformer

A strictly typed array transformer with dot-access, fluent interface and filters.

3819.1k1](/packages/selective-transformer)[deefour/transformer

Transform raw input data into consistent, immutable PHP objects

1252.2k2](/packages/deefour-transformer)

PHPackages © 2026

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