1. Go to this page and download the library: Download intellexapps/data-parser 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/ */
intellexapps / data-parser example snippets
use Intellex\DataParser\DataParser;
// Classes
class User {
public int $id;
public string $name;
public Car $car;
/** @var Role[] */ public array $roles;
}
class Car {
public string $manufacturer;
public string $model;
public int $year;
}
class Role {
public string $module;
public string $access;
}
// Data
$data = [
'id' => 100,
'name' => 'John Doe',
'car' => [
'manufacturer' => 'Volkswagen',
'model' => 'Golf',
'year' => 2023
],
'roles' => [
[ 'module' => 'news', 'access' => 'rw' ],
[ 'module' => 'video', 'access' => 'r' ],
]
];
// Parse
$dataParser = new DataParser();
$user = $dataParser->parse(User::class, $data);
use Intellex\DataParser\DataParser;
// Class
class User {
public int $id;
public string $name;
}
// Data
$data = [
[ 'id' => 1, 'name' => 'John Doe' ],
[ 'id' => 2, 'name' => 'Jane Doe' ]
];
// Parse
$dataParser = new DataParser();
$users = $dataParser->parseArray(User::class, $data);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.