PHP code example of bentools / doctrine-ulid

1. Go to this page and download the library: Download bentools/doctrine-ulid 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/ */

    

bentools / doctrine-ulid example snippets


use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 */
class Foo
{

    /**
     * @var string
     *
     * @ORM\Id()
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="\BenTools\ULIDGenerator")
     * @ORM\Column(type="string", length=26)
     */
    private $id;
    
    // ...
    
}

use Doctrine\ORM\Mapping as ORM;
use BenTools\GeneratedULIDTrait;

/**
 * @ORM\Entity()
 */
class Foo
{

    use GeneratedULIDTrait;
    
    // ... 
    
}

use Doctrine\ORM\Mapping as ORM;
use BenTools\EditableULIDTrait;

/**
 * @ORM\Entity()
 * @ORM\HasLifecycleCallbacks()
 */
class Foo
{

    use EditableULIDTrait;
    
    // ... 
    
}