1. Go to this page and download the library: Download compositephp/entity 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/ */
compositephp / entity example snippets
use Composite\Entity\AbstractEntity;
class User extends AbstractEntity
{
public function __construct(
public readonly int $id,
public string $email,
public ?string $name = null,
public bool $is_test = false,
public array $languages = [],
public Status $status = Status::ACTIVE,
public readonly \DateTimeImmutable $created_at = new \DateTimeImmutable(),
) {}
}
enum Status
{
case ACTIVE;
case BLOCKED;
}
use Composite\Entity\AbstractEntity;
use Composite\Entity\Attributes\ListOf;
class User extends AbstractEntity
{
public readonly int $id;
public function __construct(
public string $name,
#[ListOf(Setting::class)]
public array $settings = [],
) {}
}
class Setting extends AbstractEntity
{
public function __construct(
public readonly string $name,
public bool $isActive,
) {}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.