1. Go to this page and download the library: Download jdcode/dto-php 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/ */
jdcode / dto-php example snippets
use JDCode\DtoPhp\DtoPhp;
class StoreUserDto extends DtoPhp
{
public string $username;
public string $password;
public int $age;
}
use JDCode\DtoPhp\DtoPhp;
use JDCode\DtoPhp\Validations\MinLength;
use JDCode\DtoPhp\Validations\MaxLength;
use JDCode\DtoPhp\Validations\Email;
class StoreUserDto extends DtoPhp
{
#[MinLength(length: 3), MaxLength(length: 10)]
public string $username;
public string $password;
#[Email]
public string $email
public int $age;
}
use JDCode\DtoPhp\DtoPhp;
class StoreUserDto extends DtoPhp
{
public string $username;
public string $password;
public int $age;
public RoleDto $role
}
use JDCode\DtoPhp\DtoPhp;
class RoleDto extends DtoPhp
{
public int $id;
public string $name;
}
use JDCode\DtoPhp\DtoPhp;
class RoleDto extends DtoPhp
{
public int $id;
public string $name;
}
use JDCode\DtoPhp\DtoPhp;
use JDCode\DtoPhp\Casters\CastArrayWithObject;
class StoreUserDto extends DtoPhp
{
public string $username;
public string $password;
#[CastArrayWithObject(Role::class)]
public array $roles;
}