Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.91 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.91 KB

Entity datetime

Build Status Scrutinizer Code Quality Build Status Code Coverage Latest Stable Version Total Downloads License

Trait for easy manage useful datetime in entities.

Install

Install by composer

composer require redrat/entity-datetime

Usage

With Doctrine

1 - Add trait in your Entity

<?php

use RedRat\Entity\DateTimeTrait;

class Foo
{
    use DateTimeTrait;
}

2 - Set lifecycleCallbacks in your Doctrine configuration, like example below:

    fields:
        createdAt:
            type: datetime
        updatedAt:
            type: datetime
            nullable: true
            
    lifecycleCallbacks:
        prePersist: [ forgeCreatedAt ]
        preUpdate: [ forgeUpdatedAt ]

Note: More about lifecycle callbacks in Doctrine documentation.

TODO

  • API documentation.