PHP code example of kherge / uuid-bundle

1. Go to this page and download the library: Download kherge/uuid-bundle 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/ */

    

kherge / uuid-bundle example snippets


use Ramsey\Uuid\Uuid;

// The UUID factory is available as a service.
$factory = $this->container->get('kherge_uuid.uuid_factory');

// And you can use it how you normally would.
$v1 = $factory->uuid1();
$v3 = $factory->uuid3(Uuid::NAMESPACE_DNS, 'example.com');
$v4 = $factory->uuid4();
$v5 = $factory->uuid5(Uuid::NAMESPACE_DNS, 'example.com');

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 * @ORM\Table()
 */
class Entity
{
    /**
     * @ORM\Column(type="uuid")
     * @ORM\CustomIdGenerator("KHerGe\Bundle\UuidBundle\Doctrine\Id\Uuid4Generator")
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\Id()
     */
    private $id;
}

use Ramsey\Uuid\Uuid;

/**
 * @Route("/entity/{id}")
 * @ParamConverter("id")
 */
public function getAction(Uuid $id)
{
    // ... use the uuid ...
}
yaml
kherge_uuid:
    uuid_factory:
        global: true