chippyash/record-status
Composer 安装命令:
composer require chippyash/record-status
包简介
Class Status Management
README 文档
README
Quality Assurance
See the Test Contract
What?
Provides a simple helper capability for managing record or class status
Why?
When dealing with database records, there is often a case for never deleting the record. This can be because you either don't want to lose the data, or you need it in place to ensure referential integrity with other data.
This small library provides the interfaces and traits to add a status functionality to any class.
Roadmap
If you want more, either suggest it, or better still, fork it and provide a pull request.
Check out ZF4 Packages for more packages
How
A record can be in one of three states:
- active. An active record can have be changed to suspended or defunct
- suspended. A suspended record can be changed to active of defunct. You should not change the attributes of a suspended reord.
- defunct. A defunct record or class cannot have its state changed. This analogous to being deleted, except that the record data remains intact. You must not change the attributes of a defunct record.
Whilst the library provides support to manage the record status, you should also bear in mind that you will need to provide additional support to check the status in any of your other methods in a class.
In the docs directory, you'll also find an example trigger that you can use in MySql or MariaDb database server to maintain status integrity.
Coding Basics
Record Status Enum class
The Chippyash\RStatus\RecordStatus class is provided to provide the three possible
states as a an Enum(erator) using the MyCLabs Enum
library.
use Chippyash\RStatus\RecordStatus;
//create status objects
$status = RecordStatus::ACTIVE();
$status = RecordStatus::SUSPENDED();
$status = RecordStatus::DEFUNCT();
//test if status can be changed
if ($status->canChange()) {
//....
}
Enabling RecordStatus for your class
Have your class implement the RecordStatusRecordable interface. Use the RecordStatusRecording trait as a convenient implementation of the interface.
use Chippyash\RStatus\RecordStatusRecordable;
use Chippyash\RStatus\RecordStatusRecording;
class MyRecord implements RecordStatusRecordable
{
use RecordStatusRecording;
}
The RecordStatusRecording trait provides a protected $recordStatus propertyand the
following methods:
/** * Return the record status * * @return RecordStatus */ public function getStatus(); /** * Set the record status * * @param RecordStatus $status * * @return $this * * @throws RecordStatusException */ public function setStatus(RecordStatus $status); /** * Is record status == active * * @return bool */ public function isStatusActive(); /** * Is record status == suspended * * @return bool */ public function isStatusSuspended(); /** * Is record status == defunct * * @return bool */ public function isStatusDefunct();
Changing the library
- fork it
- write the test
- amend it
- do a pull request
Found a bug you can't figure out?
- fork it
- write the test
- do a pull request
NB. Make sure you rebase to HEAD before your pull request
Or - raise an issue ticket.
Where?
The library is hosted at Github. It is available at Packagist.org
Installation
Install Composer
For production
"chippyash/record-status": ">=1,<2"
For development
Clone this repo, and then run Composer in local repo root to pull in dependencies
git clone git@github.com:chippyash/record-status.git
cd record-status
composer install
To run the tests:
cd record-status
vendor/bin/phpunit -c test/phpunit.xml test/
License
This software library is released under the GNU GPL V3 or later license
This software library is Copyright (c) 2017, Ashley Kitson, UK
A commercial license is available for this software library, please contact the author. It is normally free to deserving causes, but gets you around the limitation of the GPL license, which does not allow unrestricted inclusion of this code in commercial works.
History
V1.0.0 Original release
V1.0.1 build integration
V1.0.2 typos
chippyash/record-status 适用场景与选型建议
chippyash/record-status 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.45k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「class」 「record」 「status」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chippyash/record-status 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chippyash/record-status 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chippyash/record-status 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Serves functionality of healthchecks of your application
Doctrine implementation of the MetaborStd (Statemachine) for PHP 8.2+
Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.
PHP Interface for Babel Street Text Analytics
404 'not found' and 403 'forbidden' error handlers. The 404 handler shows custom content for missing pages but not resources like CSS or JS. The 403 handler redirects to a login URL on unauthorized access.
Collection of methods that I or you usually use.
统计信息
- 总下载量: 2.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: (GPL V3+ and Proprietary) 03a6982b3e95c606b222f01c6a28a03e4ba5197a
- 更新时间: 2017-12-31