This library provides event subscriber
for Doctrine ORM, which
generates GUID in prePersist
event automatically for every
entity field with guid type.
composer require lku/doctrine-guid
- PHP 5.4+
- Doctrine ORM 2.4+
$guidGenerator = new Doctrine\ORM\Id\UuidGenerator();
$subscriber = new LKu\DoctrineGuid\EventSubscriber($guidGenerator);
$entityManager->getEventManager()->addEventSubscriber($subscriber);
/**
* @ORM\Entity
**/
class Entity
{
/**
* @ORM\Column(type="guid")
**/
protected $guid;
}
After persisting new instance of Entity
class in EntityManager
it has guid
field filled with GUID.
This library is released under the MIT License.