v3labs/doctrine-extensions

A set of minimalistic Doctrine 2 ORM extensions.

dev-master 2014-05-15 20:22 UTC

This package is auto-updated.

Last update: 2024-04-26 11:03:57 UTC


README

This library aims to be a minimalistic set of Doctrine 2 ORM extensions for php >=5.4. I'm developing this library for a project in my company. I am using it in production. The API is in no way stable(yet). More extensions will be added. I will try to keep the docs updated. Any help will be appreciated.

Timestampable

First you must register the timestampable event listener:

<?php

use V3labs\DoctrineExtensions\ORM\Timestampable\TimestampableListener;

// ...

$em->getEventManager()->addEventSubscriber(new TimestampableListener);

If you are a Symfony2 user you can add this to your config.yaml:

services:
  v3labs.doctrine_extensions.timestampable_listener:
    class:   "V3labs\DoctrineExtensions\ORM\Timestampable\TimestampableListener"
    public:  false
    tags:
       - { name: doctrine.event_subscriber }

An entity using this extension would loke like this:

<?php

namespace Some\Namespace;

use Doctrine\ORM\Mapping as ORM;
use V3labs\DoctrineExtensions\ORM\Timestampable\Timestampable;

/**
 * Event
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class Event
{
    use Timestampable;

    // Rest of your entity
}