redrat / entity-datetime
Datetime trait for entities
Installs: 3 358
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7.2
- squizlabs/php_codesniffer: ^3.3
- symfony/var-dumper: ^4.1
This package is auto-updated.
Last update: 2024-10-28 13:42:07 UTC
README
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.