Helper methods and properties for timestamping Doctrine2 entities.

Installs: 275

Dependents: 0

Stars: 5

Watchers: 1

Forks: 0

Open Issues: 0

Type: symfony-bundle

v1.0.1 2015-12-03 19:30 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.6 and later
  • Symfony 2.3 and later (including Symfony 3.0)
  • Doctrine 2.2 and later


Install via Composer

php composer.phar require fresh/timestampable-entity-bundle='~1.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.