Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.
/ doctrine-guid Public archive

Doctrine Event Subscriber for automatic GUID/UUID generation

License

Notifications You must be signed in to change notification settings

lku/doctrine-guid

Repository files navigation

Doctrine GUID Event Subscriber

Build Status Code Coverage Dependency Status

This library provides event subscriber for Doctrine ORM, which generates GUID in prePersist event automatically for every entity field with guid type.

Installation

composer require lku/doctrine-guid

Requirements

  • PHP 5.4+
  • Doctrine ORM 2.4+

Usage

Register event subscriber:

$guidGenerator = new Doctrine\ORM\Id\UuidGenerator();
$subscriber = new LKu\DoctrineGuid\EventSubscriber($guidGenerator);

$entityManager->getEventManager()->addEventSubscriber($subscriber);

Add GUID field definition to entity:

/**
 * @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.

License

This library is released under the MIT License.

About

Doctrine Event Subscriber for automatic GUID/UUID generation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages