PHP code example of pew-pew / hydrator-jms

1. Go to this page and download the library: Download pew-pew/hydrator-jms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pew-pew / hydrator-jms example snippets


$jms = PewPew\Hydrator\JMS\Builder::create();

$hydrator = PewPew\Hydrator\JMS\Builder::create()
    ->createHydrator();

$dto = $hydrator->hydrate(ExampleDTO::class, [
    'id' => 42,
    'name' => 'Vasya',
]);

// object(ExampleDTO) {
//   id: int(42),
//   name: string("Vasya"),
// }

$extractor = PewPew\Hydrator\JMS\Builder::create()
    ->createExtractor();

$data = $extractor->extract(new ExampleDTO(
    id: 42,
    name: 'Vasya',
));

// array(2) [
//   id => int(42),
//   name => string("Vasya"),
// ]