1. Go to this page and download the library: Download elysio/typed-array 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/ */
elysio / typed-array example snippets
namespace App\Models;
class User {
public string $name;
public int $age;
}
use Elysio\TypedArray\Transform;
use App\Models\User;
$data = [
['name' => 'Alice', 'age' => 28],
['name' => 'Bob', 'age' => 35]
];
$users = Transform::toClass($data, User::class);
foreach ($users as $user) {
echo "{$user->name} is {$user->age} years old.\n";
}