1. Go to this page and download the library: Download pchapl/ids 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/ */
namespace App\Data;
use PChapl\DoctrineIdBundle\Id\Base;
final class AccountId extends Base
{
}
#[ORM\Entity]
class Account
{
#[ORM\Column(type="account_id")]
private AccountId $id;
public function __construct(AccountId $id)
{
$this->id = $id;
}
public function getId(): AccountId
{
return $this->id;
}
/** @var \Hidehalo\Nanoid\Client $nanoidClient */
$factory = new class($nanoidClient) implements \PChapl\DoctrineIdBundle\Id\Factory {
public function __construct(private \Hidehalo\Nanoid\Client $nano)
{
}
public function generate(): string
{
return $this->nano->generateId();
}
};
$account1 = new Account(AccountId::new($factory));
$account2 = new Account(AccountId::fromValue($nanoidClient->generateId()));
$account3 = new Account(AccountId::fromValue(\Ramsey\Uuid\Uuid::uuid4()->toString()));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.