1. Go to this page and download the library: Download sufir/hydrator 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/ */
sufir / hydrator example snippets
use Sufir\Hydrator\Instantiator;
$instantiator = new Instantiator();
$newObject = $instantiator->newInstance('\Some\ClassName');
use Sufir\Hydrator\PlainArrayHydrator as Hydrator;
$className = '\Namespace\Domain\Entity';
$hydrateData = [
// simple properties
'firstName' => 'John',
'lastName' => 'Doe',
// id property of sub class \Namespace\Domain\Entity\Identity
'__identity:Identity_id' => 100500,
// some properties in subclass from another namespace
'__uncloneableClass:\vendor\Some\Super\Class_someProperty1' => 'value 1',
'__uncloneableClass:\vendor\Some\Super\Class_someProperty2' => null,
// unexpected properties of subclass will be ignored
'__uncloneableClass:\vendor\Some\Super\Class_unknownProperty' => '!undefined',
// internal classes cannot be created and injected (in current version)
//'__stdClass:\stdClass_unknownProperty' => '!undefined',
];
/* @var $object PrivateConstructor */
$object = $this->hydrator->hydrate($data, $className);
var_dump($object);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.