incompass / timestampable-bundle
为symfony和doctrine提供简单高效的时戳
v3.0.0
2023-01-20 19:42 UTC
Requires
- php: >=8.0
Requires (Dev)
- doctrine/doctrine-bundle: *
- doctrine/orm: *
- phpunit/phpunit: 9.*
- symfony/framework-bundle: 4.*
- symfony/yaml: ^5.0
README
TimestampableBundle
此包允许您简单地通过将 use TimestampInterface
和 use TimestampTrait
添加到 doctrine 实体类中,使其自动添加 created_at 和 updated_at 字段,并在插入和更新时自动更新这些字段。
安装
Composer
composer require incompass/timestampable-bundle
使用方法
将 TimestampInterface 添加到您的 doctrine 实体中。
class {Entity} implements TimestampInterface
将 TimestampTrait 特性添加到您的 doctrine 实体中。
use TimestampTrait
更新您的数据库模式
php bin/console doctrine:schema:update --force
现在所有实体都将保存 created_at 和 updated_at 字段。
贡献者
Joe Mizzi (casechek/incompass)