定制 mof/timestampable 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mof/timestampable

Composer 安装命令:

composer require mof/timestampable

包简介

Generates automatically creation and update's date of Doctrine entity property

README 文档

README

Build Status

Presentation

This little library for Doctrine projects allows you to automatically handle creation and update on certain properties of your entity.

How install

You need to install it via composer :

composer require mof/timestampable

Then you need to register the annotations and add the event subscriber to the Doctrine event manager :

AnnotationRegistry::registerLoader('class_exists'); //This register the annotation

$annotationReader = new AnnotationReader();
$eventManager->addEventSubscriber(new TimestampableSubscriber($annotationReader));

You can give to the TimestampableSubcriber constructor any class that implements the Doctrine\Common\Annotations\Reader interface.

Then you ready to go.

Usage

In your entity, you can add the events the property will listen to, there are 2 events available :

/**
 * When an entity is created
 * @var \DateTime
 * @ORM\Column(type="datetime", name="created_at")
 * @Timestampable(on=Timestampable::ON_CREATE)
 */
protected $createdAt;
/**
 * When an entity is updated (the date is also set when an entity is created)
 * @var \DateTime
 * @ORM\Column(type="datetime", name="updated_at")
 * @Timestampable(on=Timestampable::ON_UPDATE)
 */
protected $updatedAt;

Tests

You can run the tests by cloning the project and then type :

composer install
vendor/bin/codecept run

The tests use sqlite for the database behind the scene, for more information, see https://www.php.net/manual/fr/sqlite.installation.php.

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固