1. Go to this page and download the library: Download galactic-shrine/gsid 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/ */
galactic-shrine / gsid example snippets
use GalacticShrine\GsId\GsId;
use GalacticShrine\GsId\GsIdCase;
use GalacticShrine\GsId\GsIdFormat;
use GalacticShrine\GsId\GsIdValidator;
$id = GsId::newGsId();
echo $id->toString(GsIdFormat::N, GsIdCase::Lower);
echo $id->toString(GsIdFormat::D, GsIdCase::Upper);
$parsed = GsId::fromString((string) $id);
if (GsIdValidator::isValid((string) $id)) {
// Identifiant valide.
}
use GalacticShrine\GsId\GsIdCase;
use GalacticShrine\GsId\GsIdFormat;
use GalacticShrine\GsId\GsIdOptions;
GsIdOptions::configure(
defaultCase: GsIdCase::Lower,
defaultTextFormat: GsIdFormat::N,
defaultJsonFormat: GsIdFormat::D,
defaultDatabaseFormat: GsIdFormat::N,
);
GsIdOptions::lock();
use GalacticShrine\GsId\Bridge\Doctrine\Types\GsidType;
use Doctrine\ORM\Mapping as ORM;
use GalacticShrine\GsId\Bridge\Doctrine\Types\GsidType;
use GalacticShrine\GsId\GsId;
#[ORM\Entity]
final class ExampleEntity
{
#[ORM\Id]
#[ORM\Column(type: GsidType::Name, unique: true)]
private ?GsId $id = null;
}