todstoychev / timestampable
Automatic timestamps for Symfony entities.
Installs: 52
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:bundle
Requires
- php: >=8.0
- symfony/config: >=6.0.0
- symfony/orm-pack: >=2.0.0
This package is not auto-updated.
Last update: 2024-11-11 02:54:20 UTC
README
- symfony >= 3.0
- php >= 7.0
Installation
Nothing special:
composer require todstoychev/timestampable
;- Add to AppKernel
new Todstoychev\Timestampable\TimestampableBundle(),
Usage
Entity that will use automatic timestamps should implement Todstoychev\TimestampableBundle\Entity\TimestampableInterface
.
The interface implementation is released in Todstoychev\TimestampableBundle\Entity\Timestampable
trait.
So in your entity:
use Todstoychev\TimestampableBundle\Entity\Timestampable; use Todstoychev\TimestampableBundle\Entity\Timestampable; class MyEntity implements TimestampableInterface { use Timestampable; }
Timestampable trait adds to entity 2 fields: createdAt and updatedAt. Describe those 2 in your entity configuration. If you are using anotations, override those 2 properties in your entity class.
That's all.