PHPackages                             zero-to-prod/transformable - 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. zero-to-prod/transformable

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

zero-to-prod/transformable
==========================

Transform a class into different types.

v71.1.0(10mo ago)18.4k↑660.7%114MITPHPPHP &gt;=7.1.0CI passing

Since Sep 3Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/zero-to-prod/transformable)[ Packagist](https://packagist.org/packages/zero-to-prod/transformable)[ Docs](https://github.com/zero-to-prod/transformable)[ Fund](https://github.com/sponsors/zero-to-prod)[ RSS](/packages/zero-to-prod-transformable/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (11)Used By (14)

Zerotoprod\\Transformable
=========================

[](#zerotoprodtransformable)

[![](./art/logo.png)](./art/logo.png)

[![Repo](https://camo.githubusercontent.com/9a90a3efeee26aed7d7f2feee9cd84566a26f9c362cc773b184d076210906e1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769746875622d677261793f6c6f676f3d676974687562)](https://github.com/zero-to-prod/transformable)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/67eee114a90b0067dab0ec4dbb0e05e1a70f95bbe01ac1f8c4474576a7c636a9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f7472616e73666f726d61626c652f746573742e796d6c3f6c6162656c3d74657374)](https://github.com/zero-to-prod/transformable/actions)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/26235eae1db74d34e2f5848b9da35f4584c791020aec3286f0816a3d95040a2a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a65726f2d746f2d70726f642f7472616e73666f726d61626c652f6261636b77617264735f636f6d7061746962696c6974792e796d6c3f6c6162656c3d6261636b77617264735f636f6d7061746962696c697479)](https://github.com/zero-to-prod/transformable/actions)[![Packagist Downloads](https://camo.githubusercontent.com/53f2120e67e6d9e86bb0264ca6366b7556dac492d8840b8812140c88d6698e92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a65726f2d746f2d70726f642f7472616e73666f726d61626c653f636f6c6f723d626c7565)](https://packagist.org/packages/zero-to-prod/transformable/stats)[![Packagist Version](https://camo.githubusercontent.com/5b8f4b7e994e5f77bd2aa55eca10a78119559c1fe315acb5ba31a7dd267d08db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a65726f2d746f2d70726f642f7472616e73666f726d61626c653f636f6c6f723d663238643161)](https://packagist.org/packages/zero-to-prod/transformable)[![GitHub repo size](https://camo.githubusercontent.com/06a2d5cc47a952ae49b260e4cdb39a645021c647a3daee9e07c326a1db2f83eb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f7a65726f2d746f2d70726f642f7472616e73666f726d61626c65)](https://github.com/zero-to-prod/transformable)[![License](https://camo.githubusercontent.com/e553afd07b558bccfea11af6d82ff9e1e2ba08d6c81e9b7c76b0dcf69bef5e61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a65726f2d746f2d70726f642f7472616e73666f726d61626c653f636f6c6f723d726564)](https://github.com/zero-to-prod/transformable/blob/main/LICENSE.md)[![wakatime](https://camo.githubusercontent.com/2d1fcb4e941d8ba113052592a6953e33817c9428fdf640d434ede89e744ce32e/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f6769746875622f7a65726f2d746f2d70726f642f7472616e73666f726d61626c652e737667)](https://wakatime.com/badge/github/zero-to-prod/transformable)[![Hits-of-Code](https://camo.githubusercontent.com/7347fca3dc6086a2aca054fffac7e89292386c9f1697a442b6ab0d8929d75d89/68747470733a2f2f686974736f66636f64652e636f6d2f6769746875622f7a65726f2d746f2d70726f642f7472616e73666f726d61626c653f6272616e63683d6d61696e)](https://hitsofcode.com/github/zero-to-prod/transformable/view?branch=main)

Contents
--------

[](#contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
    - [Additional Packages](#additional-packages)
- [Documentation Publishing](#documentation-publishing)
    - [Automatic Documentation Publishing](#automatic-documentation-publishing)
- [Usage](#usage)
    - [Methods](#methods)
- [Local Development](./LOCAL_DEVELOPMENT.md)
- [Contributing](#contributing)

Introduction
------------

[](#introduction)

Transform a class into different types.

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

[](#requirements)

- PHP 7.1 or higher.

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

[](#installation)

Install `Zerotoprod\Transformable` via [Composer](https://getcomposer.org/):

```
composer require zero-to-prod/transformable
```

This will add the package to your project’s dependencies and create an autoloader entry for it.

### Additional Packages

[](#additional-packages)

- [DataModel](https://github.com/zero-to-prod/data-model): Transform data into a class.
- [DataModelHelper](https://github.com/zero-to-prod/data-model-helper): Helpers for a `DataModel`.
- [DataModelFactory](https://github.com/zero-to-prod/data-model-factory): A factory helper to set the value of your `DataModel`.

Documentation Publishing
------------------------

[](#documentation-publishing)

You can publish this README to your local documentation directory.

This can be useful for providing documentation for AI agents.

This can be done using the included script:

```
# Publish to default location (./docs/zero-to-prod/transformable)
vendor/bin/zero-to-prod-transformable

# Publish to custom directory
vendor/bin/zero-to-prod-transformable /path/to/your/docs
```

### Automatic Documentation Publishing

[](#automatic-documentation-publishing)

You can automatically publish documentation by adding the following to your `composer.json`:

```
{
  "scripts": {
    "post-install-cmd": [
      "zero-to-prod-transformable"
    ],
    "post-update-cmd": [
      "zero-to-prod-transformable"
    ]
  }
}
```

Usage
-----

[](#usage)

To use the `Zerotoprod\Transformable\Transformable` trait in your class, simply include it:

```
use Zerotoprod\Transformable\Transformable;

class YourDataModel
{
    use Transformable;

    public $name;
    public $email;
}

$model = new YourDataModel();
$model->name = 'John Doe';
$model->email = 'john.doe@example.com';

$array = $model->toArray();
$json = $model->toJson();
```

### Methods

[](#methods)

- `toArray(): array` Converts the object’s properties into an associative array.
- `toJson(): string` Converts the object’s properties into a JSON string.

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

[](#contributing)

Contributions, issues, and feature requests are welcome! Feel free to check the [issues](https://github.com/zero-to-prod/transformable/issues) page if you want to contribute.

1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Create a new Pull Request.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance54

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.8% 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 ~40 days

Recently: every ~77 days

Total

10

Last Release

307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/502649f05d36c87d494988bd99193a4d908d345335d99c080928a726277371f5?d=identicon)[zero-to-prod](/maintainers/zero-to-prod)

---

Top Contributors

[![zero-to-prod](https://avatars.githubusercontent.com/u/61474950?v=4)](https://github.com/zero-to-prod "zero-to-prod (23 commits)")[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (1 commits)")

---

Tags

arrayphptransformablezero-to-prod

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zero-to-prod-transformable/health.svg)

```
[![Health](https://phpackages.com/badges/zero-to-prod-transformable/health.svg)](https://phpackages.com/packages/zero-to-prod-transformable)
```

###  Alternatives

[zero-to-prod/data-model

Transforms Data into Type-Safe DTOs.

14231.6k32](/packages/zero-to-prod-data-model)

PHPackages © 2026

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