The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

1090 Modules
617 Ready
473 Need Help
🏆 Leaderboard
Actively Maintained v1.0.1

DTO Toolkit for Magento 2

blackbird/dto-toolkit

Provides tooling to create and manage Data Transfer Objects in Magento 2 while retaining DI, plugins, and preferences, with automatic hydration from arrays.

307
Downloads
Below average
3
GitHub Stars
Below average
23d ago
Last Release
0
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
17 warnings
L1 PHPStan

Tested on Magento 2.4.9

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.0.1 on Magento 2.4.9
Jun 1, 2026

Share This Module's Status

DTO Toolkit for Magento 2 Magento compatibility status badge

README

Loaded from GitHub

dto-toolkit

The Magento 2 DTO Toolkit Module provides the tools for creating Data Transfer Objects (DTO) in Magento 2 while retaining Magento's key features such as plugins, preferences, etc.

This module aims to enhance the development experience by offering a structured approach to handling data transfer within Magento applications.

FeaturesInstallationUsageMore modules

Features

  • Easy DTO Creation: Simplifies the process of creating and managing DTOs.
  • Magento Integration: Maintains full compatibility with Magento's DI system, plugins, and preferences.
  • Auto Hydration: Provides a way to automatically hydrate your DTO with an array.

Installation

Requirements

  • PHP >= 7.4
composer require blackbird/dto-toolkit
php bin/magento setup:upgrade

In production mode, do not forget to recompile and redeploy the static resources.

Usage

To instantiate your DTO while maintains full compatibility with Magento 2, please use the provided DTOFactory

use Blackbird\DTOToolkit\Model\Factory\DTOFactory;

/** @var DTOFactory $dtoFactory **/
protected $dtoFactory;

public function __construct(
    DTOFactory $dtoFactory
) {
  $this->dtoFactory = $dtoFactory;
}

[...]

$myDtoInstance = $this->dtoFactory->create(MyDTO::class);

To automatically hydrate your DTO instance with an array

use Blackbird\DTOToolkit\Model\Factory\DTOFactory;

/** @var DTOFactory $dtoFactory **/
protected $dtoFactory;

public function __construct(
    DTOFactory $dtoFactory
) {
  $this->dtoFactory = $dtoFactory;
}

[...]

myArray = [
  'key_one' => 1,
  'key_two' => 2
];

$myDtoInstance = $this->dtoFactory->create(MyDTO::class, $myArray);

Warning, if your DTO class doesn't have the properties keyOne or keyTwo, they will not be hydrated.

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.