PHP code example of ferfabricio / hydrator
1. Go to this page and download the library: Download ferfabricio/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/ */
ferfabricio / hydrator example snippets
class Example
{
private $test;
public function setTest($test)
{
$this->test = $test;
}
public function getTest()
{
return $this->test;
}
}
use FerFabricio\Hydrator\Hydrate;
class Example
{
private $test;
public function setTest($test)
{
$this->test = $test;
}
public function getTest()
{
return $this->test;
}
}
$myData = [
'test' => 'this is a test'
];
$example = Hydratate::toObject(Example::class, $myData);
echo $example->getTest(); // This line will print: this is a test