PHP code example of krifollk / hydrator

1. Go to this page and download the library: Download krifollk/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/ */

    

krifollk / hydrator example snippets




class User 
{
    private $name;
    protected $surname;
}

$hydrator = new Krifollk\Hydrator\Hydrator();
$user = new User();

$hydrator->hydrate($user, ['name' => 'John', 'surname' => 'Doe']);

print_r($user);




class User
{
    private $name = 'John';
    protected $surname = 'Doe';
}


$hydrator = new Krifollk\Hydrator\PropertyExtractor();
$user = new User();

$result = $hydrator->extractProperties($user, ['name', 'surname']);

print_r($result);