1. Go to this page and download the library: Download squidit/array-to-object 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/ */
class Car
{
public function __construct(
public string $color,
public Honda $manufacturer,
) {}
}
$data = [
'color' => 'black',
'manufacturer' => [ // <-- Honda::class
'name' => 'Beautiful Street 124',
'city' => 'Rotterdam',
'employeeList' => []
],
];
use SquidIT\Hydrator\Attributes\ArrayOf;
class Honda implements ManufacturerInterface
{
/**
* @param array<int, Employee> $employeeList
*/
public function __construct(
public string $name,
public string $city,
#[ArrayOf(Employee::class)]
public array $employeeList,
) {}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.