1. Go to this page and download the library: Download koriym/csv-entities 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/ */
koriym / csv-entities example snippets
final class Memo
{
public string $id,
public string $title
}
final class Todo
{
public string $id,
public string $title,
/** @var array<Memo> */
public array $memos,
}
final class Memo
{
public function __construct(
public string $id,
public string $title
){}
}
final class Todo
{
/** @var array<Memo> */
public array $memos;
public function __construct(
public string $id,
public string $title,
string|null $memoIds,
string|null $memoBodies
){
$this->memos = (new CsvEntities())(Memo::class, $memoIds, $memoBodies);
}
}
$todoList = $pdo->fetchAll(PDO::FETCH_FUNC, static function (...$args) {
return new Todo(...$args);
});
final class Todo
{
public string $id,
public string $title,
/** @var array<Memo> */
public array $memos,
}
$this->memos = (new CsvEntities())->get("\t", Memo::class, $memoIds, $memoBodies); // tab separator
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.