konstantin-kuklin / doctrine-dto
Installs: 139
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/konstantin-kuklin/doctrine-dto
Requires (Dev)
- php: >=5.3
- doctrine/orm: 2.2.*
This package is not auto-updated.
Last update: 2025-09-27 22:17:39 UTC
README
What is DoctrineDto?
Library for getting Data Transfer Object from a database through Doctrine. If you are using a service approach to development, this library can be useful for you.
Requirements
Single dependency: Doctrine orm library Also you need to have PHP >= 5.3
Installation
The simplest way to add DoctrineDto is execute command:
composer require "konstantin-kuklin/doctrine-dto" "dev-master"
Usage example
Initialize Dto -> Entity class map:
// static map rules here: $map = new Map( array( 'Path\To\UserEntity' => 'Path\To\UserDto', 'Path\To\AnotherEntity' => 'Path\To\AnotherDto' ) ); // class to dynamic class map generation $map->addMapGeneratorElement(new EntityDtoSimpleGenerator()); // set class map DtoClassMap::setMap($map, $map->getFlippedMap());
Add custom hydrator in your code with such example:
$em->getConfiguration()->addCustomHydrationMode('DtoHydrator', 'KonstantinKuklin\DoctrineDto\Hydrator\DtoHydrator'); $query = $em->createQuery('SELECT u FROM CmsUser u'); $results = $query->getResult('DtoHydrator');
Usage with Symfony
For using with Symfony framework go to DoctrineDtoBundle.