1. Go to this page and download the library: Download quillstack/serializer 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/ */
quillstack / serializer example snippets
use Quillstack\Serializer\Attributes\Exposed;
#[Table('users')]
final class User
{
public function __construct(
#[Id, Exposed] public ?int $id = null,
#[Column, Exposed] public string $email = '',
#[Column] public string $password = '',
#[Column('created_at'), Exposed(name: 'created_at')] public ?DateTimeImmutable $createdAt = null,
) {
}
}
final class UserResponse extends Response
{
public function __construct(private readonly Serializer $serializer)
{
parent::__construct();
}
public function setUser(User $user): self
{
$this->user = $user;
return $this;
}
public function send(): array
{
return $this->serializer->toArray($this->user);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.