承接 sjaakp/yii2-novelty 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sjaakp/yii2-novelty

Composer 安装命令:

composer require sjaakp/yii2-novelty

包简介

Property indicating novelty of Yii2 ActiveRecord.

README 文档

README

Property indicating novelty of Yii2 ActiveRecord

Latest Stable Version Total Downloads License

yii2-novelty is a behavior that adds a property with the name 'novelty' to an ActiveRecord in the Yii2 PHP framework. This property has one of the following three values:

  • 'new' in case the record is created since the user visited the site previously;
  • 'updated' in case the record is updated since the user visited the site previously;
  • null in other cases.

The class NoveltyBehavior extends om Yii's TimestampBehavior. The value of novelty is based on the attribute values of TimestampBehavior, usually called 'created_at' and 'updated_at', and on the time the user visited the site previously. The previous visit time is stored in two cookies.

Installation

Install yii2-novelty in the usual way with Composer. Add the following to the require section of your composer.json file:

"sjaakp/yii2-novelty": "*"

or run:

composer require sjaakp/yii2-novelty

You can manually install yii2-novelty by downloading the source in ZIP-format.

Using NoveltyBehavior

Add NoveltyBehavior to your ActiveRecord like this:

<?php

use sjaakp\novelty\NoveltyBehavior;

class MyRecord extends ActiveRecord
{
    public function behaviors( ) {
	    return [
	        [
	            'class' => NoveltyBehavior::class,
	            // ... options ...
	        ],
	        // ... more behaviors ...
	    ];
	}
	...
}

NoveltyBehavior extends on yii\behaviors\TimestampBehavior, so you shouldn't use them together.

After adding NoveltyBehavior the ActiveRecord has an extra property 'novelty', which can be read like any other property, f.i. with:

$novelty = $record->novelty;

It is a read-only property, so it cannot be written to.

Options

In most cases, NoveltyBehavior will work out of the box. The following options are available for finetuning. All are optional.

  • noveltyAttribute string Name of the read-only attribute. Default: 'novelty'.
  • visitCookie string Name of the cookie storing the previous visit time. Default: 'visit'.
  • visitStamina integer Expiration time of the visit-cookie in seconds. Default: 31536000 (one year).
  • cacheCookie string Name of the cookie caching the previous visit time. Default: 'visit-cache'.
  • cacheStamina integer Expiration time of the cache-cookie in seconds. Default: 1800 (30 minutes).
  • format null|string PHP date() format of the TimestampBehavior attributes. If null, this will be set with the right values for value is null, or for value set to new Expression('NOW()'), i.e. virtually all use cases. Only in really exotic cases might this be set to anything else than null. Default: null.
  • noveltyValues array Possible values assigned to novelty. Default: see source.

NoveltyBehavior also inherits all the options of yii\behaviors\TimestampBehavior.

sjaakp/yii2-novelty 适用场景与选型建议

sjaakp/yii2-novelty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 51 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 07 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「extension」 「Behavior」 「yii」 「yii2」 「novelty」 「freshness」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sjaakp/yii2-novelty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sjaakp/yii2-novelty 我们能提供哪些服务?
定制开发 / 二次开发

基于 sjaakp/yii2-novelty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-04