PHP code example of phore / hydrator

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

    

phore / hydrator example snippets


class UserData {
    /**
     * @var string
     */
    public $name;
    
    /**
    * Assoc Array 
    * @var array<string, ClassType2> 
    */
    public $map;
    
    /**
     * @var int
     */
    public $age;
}

$input = ["name"=>"bob", "age"=>37];

$userData = phore_hydrate($input, UserData::class);

assert( $userData instanceof UserData);

class Entity1 {
    public $p1;

    public function __hydrate(array $input) : array
    {
        // .. modify input to match the object ..
        return $input;
    }
}