1. Go to this page and download the library: Download alesitom/hybrid-id-doctrine 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/ */
alesitom / hybrid-id-doctrine example snippets
use Doctrine\DBAL\Types\Type;
use HybridId\Doctrine\HybridIdType;
Type::addType(HybridIdType::NAME, HybridIdType::class);
use Doctrine\ORM\Mapping as ORM;
use HybridId\Doctrine\HybridIdGenerator;
#[ORM\Entity]
class User
{
#[ORM\Id]
#[ORM\Column(type: 'hybrid_id', length: 29)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: HybridIdGenerator::class)]
private string $id;
// ...
public function getId(): string
{
return $this->id;
}
}
#[ORM\Entity]
class Order
{
#[ORM\Id]
#[ORM\Column(type: 'hybrid_id', length: 29)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: HybridIdGenerator::class)]
private string $id;
public static function hybridIdPrefix(): string
{
return 'ord';
}
}
use HybridId\Doctrine\HybridIdGenerator;
use HybridId\HybridIdGenerator as CoreGenerator;
$core = new CoreGenerator(profile: 'extended', node: 'A1',
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.