PHPackages                             picamator/transfer-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. picamator/transfer-object

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

picamator/transfer-object
=========================

A modern Symfony-compatible Transfer Object Generator with property hooks, FixedArray, and asymmetric visibilities.

5.6.0(2mo ago)21662MITPHPPHP &gt;=8.5CI passing

Since Dec 30Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (26)Versions (59)Used By (0)

[![Transfer Object Generator](.github/transfer-object-generator.jpg)](.github/transfer-object-generator.jpg)

[![CI workflow](https://github.com/picamator/transfer-object/actions/workflows/ci.yml/badge.svg?event=push)](https://github.com/picamator/transfer-object/actions)[![License](https://camo.githubusercontent.com/4ebec2e8895605a1ca64eab08afa8a178220f2b3b9a560ddc1990a7a337ab03e/68747470733a2f2f706f7365722e707567782e6f72672f706963616d61746f722f7472616e736665722d6f626a6563742f6c6963656e7365)](https://packagist.org/packages/picamator/transfer-object)[![OpenSSF Best Practices](https://camo.githubusercontent.com/d0e68de456505df7e0382200201611770d95319268f235b7d60a526d911d834e/68747470733a2f2f7777772e626573747072616374696365732e6465762f70726f6a656374732f31313436352f6261646765)](https://www.bestpractices.dev/projects/11465)[![PHP Version Require](https://camo.githubusercontent.com/d2a2970484d6a17d6eb0d0196723737087c72f417c352bafc9e6d253f0d643e2/68747470733a2f2f706f7365722e707567782e6f72672f706963616d61746f722f7472616e736665722d6f626a6563742f726571756972652f706870)](https://packagist.org/packages/picamator/transfer-object)[![Symfony Compatibility](https://camo.githubusercontent.com/7a848ad04d86eff0c6c0ba61e28f81215db4f86cc3a5e41ec7d621d5f0d7b4a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d253545382e302d626c7565)](https://github.com/picamator/transfer-object/tree/development?tab=readme-ov-file#key-features)[![Wiki](https://camo.githubusercontent.com/2981f7431c3a08e4506e4fc3d8c323a80b1b6ee42125b9be511cad84497db2bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f77696b692d617661696c61626c652d627269676874677265656e)](https://github.com/picamator/transfer-object/wiki)[![Latest Stable Version](https://camo.githubusercontent.com/eaf9c6192e9cfb6ddec910ffc336662456237b500ad8162c476175ee7f353d27/68747470733a2f2f706f7365722e707567782e6f72672f706963616d61746f722f7472616e736665722d6f626a6563742f76)](https://packagist.org/packages/picamator/transfer-object)

Transfer Object Generator
=========================

[](#transfer-object-generator)

Would you like to build Symfony-compatible transfer objects?

You're in the right place! 🎉

Imagine you have a Rest API response:

```
{
    "firstName": "Jan",
    "lastName": "Kowalski"
}
```

Running the following interactive [console command](https://github.com/picamator/transfer-object/wiki/Console-Commands#definition-generate):

```
$ ./vendor/bin/definition-generate
```

Generates a `YML` [definition file](https://github.com/picamator/transfer-object/wiki/Definition-File):

```
Customer:
  firstName:
    type: string
  lastName:
    type: string
```

Then, running [console command](https://github.com/picamator/transfer-object/wiki/Console-Commands#transfer-generate):

```
$ ./vendor/bin/transfer-generate [-c|--configuration CONFIGURATION]
```

Builds the transfer object:

```
$customerTransfer = new CustomerTransfer();
$customerTransfer->firstName = 'Jan';
$customerTransfer->lastName = 'Kowalski';
```

Key Features
------------

[](#key-features)

**Symfony Compatibility:**

- Provides Symfony console command:
    - [TransferGeneratorCommand](https://github.com/picamator/transfer-object/wiki/Console-Commands#transfer-generate)
    - [TransferGeneratorBulkCommand](https://github.com/picamator/transfer-object/wiki/Console-Commands#transfer-generate-bulk)
    - [DefinitionGeneratorCommand](https://github.com/picamator/transfer-object/wiki/Console-Commands#definition-generate)
- Includes Symfony services:
    - [TransferGeneratorFacade](https://github.com/picamator/transfer-object/wiki/Facade-Interfaces#transfer-object-generator)
    - [DefinitionGeneratorFacade](https://github.com/picamator/transfer-object/wiki/Facade-Interfaces#definition-generator)
- Enables automatic Symfony request query data mapping
- Supports [Symfony validator](https://github.com/picamator/transfer-object/wiki/Definition-File#attributes) attributes

**Transfer Object:**

- Offers methods:
    - `fromArray()`
    - `toArray()`
- Implements standard interfaces:
    - `IteratorAggregate`
    - `JsonSerializable`
    - `Countable`
- Handles embedded and collection transfer objects.
- Works with PHP primitive data types.
- Extends compatibility to advanced types:
    - `BackedEnum`
    - `DateTime`
    - `DateTimeImmutable`
    - `BcMath\Number`
- Supports asymmetric property visibility.
- Integrates with external transfer objects.

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

[](#installation)

**Composer installation:**

The Transfer Object Generator is available on [Packagist](https://packagist.org/packages/picamator/transfer-object)and can be installed using [Composer](https://getcomposer.org/):

```
$ composer require picamator/transfer-object
```

VersionPHPSymfony≤ 4.0.08.47.3≥ 5.0.08.58.0**Directory Structure:**

After installation, the following directory structure is recommended:

- `src/Generated`: transfer objects directory
- `src/config/generator.config.yml`: generator's [configuration file](https://github.com/picamator/transfer-object/wiki/Console-Commands#configuration)
- `src/config/definition/*.transfer.yml`: transfer objects [definition files](https://github.com/picamator/transfer-object/wiki/Definition-File), where each of them groups transfer objects definitions by business domain, e.g. `payment.transfer.yml`, `sales.transfer.yml`, etc.

With this setup, `generator.config.yml` looks like:

```
# $schema: ./../vendor/picamator/transfer-object/schema/config.schema.json
generator:
    transferNamespace: "YourVendorNamespace\\YourProjectNamespace\\Generated"
    transferPath: "${PROJECT_ROOT}/src/Generated"
    definitionPath: "${PROJECT_ROOT}/config/definition"
```

Where `YourVendorNamespace\\YourProjectNamespace` should be replaced with your vendor and project namespace.

Additionally, `.gitignore` should contain:

```
# transfer objects
src/Generated/_tmp
src/Generated/transfer.lock
```

Then, running command generates transfer objects:

```
$ ./vendor/bin/transfer-generate -c config/generator.config.yml
```

Tip

For large projects, each module can have its own generator configuration. Please use [bulk command](https://github.com/picamator/transfer-object/wiki/Console-Commands#transfer-generate-bulk)to generate transfer objects for the multi-configuration setup.

Documentation
-------------

[](#documentation)

- [Project's Wiki](https://github.com/picamator/transfer-object/wiki)
- [Examples](examples)
- [Integration Test Scenario](tests/integration/DefinitionGenerator/data/README.md)

Publications
------------

[](#publications)

1. [Sergii Pryz, "Data Transfer Objects and Property Hooks" PHP Architect Magazine, June 2025](https://www.phparch.com/article/2025-06-data-transfer-objects-and-property-hooks/)

Acknowledgment
--------------

[](#acknowledgment)

Many thanks ❤️ for your contribution, support, feedback and simply using the Transfer Object Generator!

Contribution
------------

[](#contribution)

If you find this project useful, please ⭐ star the repository. Follow the project to stay updated with all activities.

If you have suggestions for improvements or new features, feel free to:

- Create an issue
- Submit a pull request

Here is a [Contribution Guide](CONTRIBUTING.md).

This project is released with a [Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project and its community, you agree to abide by those terms.

Security Commitment
-------------------

[](#security-commitment)

The project applies [OpenSSF Best Practices](https://www.bestpractices.dev/en/projects/11465/passing).

For reporting security vulnerabilities, please follow [Security Policy](https://github.com/picamator/transfer-object/security/policy).

License
-------

[](#license)

Transfer Object Generator is free and open-source software licensed under the MIT License.

For more details, please see the [LICENSE](LICENSE) file.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

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

Total

56

Last Release

72d ago

Major Versions

1.9.0 → 2.0.02025-04-27

2.3.0 → 3.0.02025-09-14

3.1.0 → 4.0.02025-10-24

4.0.0 → 5.0.02025-11-28

PHP version history (2 changes)1.0.0PHP &gt;=8.4

5.0.0PHP &gt;=8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/87835b8aad10c1a1fcdfb499cebd35ca4959255c148f452cde9ec3055d2ecb2c?d=identicon)[Sergii Pryz](/maintainers/Sergii%20Pryz)

---

Top Contributors

[![picamator](https://avatars.githubusercontent.com/u/4932996?v=4)](https://github.com/picamator "picamator (1023 commits)")[![sdienelt](https://avatars.githubusercontent.com/u/31069270?v=4)](https://github.com/sdienelt "sdienelt (3 commits)")

---

Tags

automationcode-generatordata-transfer-objectdtodto-generatorgeneratorphpsymfonysymfony-consoletransfer-objecttransfer-object-generatorsymfonygeneratordata-transfer-objectdtosymfony-consoledto-generatordata-transfer-object-generator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/picamator-transfer-object/health.svg)

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

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[sculpin/sculpin

Static Site Generator

1.5k102.8k12](/packages/sculpin-sculpin)

PHPackages © 2026

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