Helper methods and properties for timestamping Doctrine2 entities.

Installs: 275

Dependents: 0

Stars: 5

Watchers: 1

Type: symfony-bundle

v1.0.0 2014-11-23 00:00 UTC


Helper methods and properties for timestamping Doctrine2 entities.

Scrutinizer Quality Score Build Status License Latest Stable Version Total Downloads Dependency Status SensioLabsInsight Gitter


  • PHP 5.4 and later
  • Symfony 2.3 and later
  • Doctrine 2.2 and later


Install via Composer

php composer.phar require fresh/timestampable-entity-bundle='v1.0.0'

Register the bundle

To start using the bundle, register it in app/AppKernel.php:

public function registerBundles()
    $bundles = [
        // Other bundles...
        new Fresh\TimestampableEntityBundle\FreshTimestampableEntityBundle(),



Create Player entity that implements TimestampableInterface and use trait TimestampableTrait:

namespace Acme\AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Fresh\TimestampableEntityBundle\Model\TimestampableInterface;
use Fresh\TimestampableEntityBundle\Traits\TimestampableTrait;

 * Player Entity
 * @ORM\Entity()
 * @ORM\Table(name="players")
class Player implements TimestampableInterface
    // Methods and properties for timestampable entity
    use TimestampableTrait;

     * @var int $id
     * @ORM\Id
     * @ORM\Column(name="id", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
    protected $id;

Now Player entity has properties createdAt and updatedAt which come from TimestampableTrait. There are also setters and getters for them.

Implementing TimestampableInterface is required! There are two listeners for prePersist and preUpdate Doctrine2 events, that process timestamp properties of timestampable entities.