ebidtech/collection
Composer 安装命令:
composer require ebidtech/collection
包简介
A set of interfaces and traits to speed up the creation of collections
README 文档
README
A set of interfaces and traits to speed up the creation of collections.
Requirements
- PHP >= 5.4
Installation
The recommended way to install is through composer.
Just create a composer.json file for your project:
{
"require": {
"ebidtech/collection": "@stable"
}
}
Tip: browse ebidtech/collection page to choose a stable version to use, avoid the @stable meta constraint.
And run these two commands to install it:
$ curl -sS https://getcomposer.org/installer | php
$ composer install
Now you can add the autoloader, and you will have access to the library:
<?php require 'vendor/autoload.php';
Usage
Collection class example:
use EBT\Collection\CollectionDirectAccessInterface; use EBT\Collection\CountableTrait; use EBT\Collection\DirectAccessTrait; use EBT\Collection\EmptyTrait; use EBT\Collection\GetItemsTrait; use EBT\Collection\IterableTrait; /** * TestCollection */ class TestCollection implements CollectionDirectAccessInterface { use CountableTrait; use DirectAccessTrait; use EmptyTrait; use GetItemsTrait; use IterableTrait; /** * @var array */ protected $items = array( 'test1' => 'val1', 'test2' => 'val2', 'test3' => 'val3' ); }
From outside you can:
- iterate (due to IterableTrait)
- direct access using get() (due to DirectAccessTrait)
- use count() (due to CountableTrait)
Outside access example:
$collection = new TestCollection(); echo count($collection); // will print 3 echo $collection->get('test1'); // will print val1 foreach ($collection as $key => $val) { // will result in: // test1 val1 // test2 val2 // test3 val3 echo sprintf("%s %s", $key, $val); }
Notes:
- Traits use have an abstract getCollection() method that needs to be implemented on collection class, the GetCollectionTrait makes a simple implementation, you can override it if the property that holds the internal array is not named collection
Upgrading
Contributing
See CONTRIBUTING file.
Credits
- Ebidtech developer team, collection Lead developer Eduardo Oliveira (eduardo.oliveira@ebidtech.com).
- All contributors
License
Collection library is released under the MIT License. See the bundled LICENSE file for details.
ebidtech/collection 适用场景与选型建议
ebidtech/collection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 122.92k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2013 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「abstraction」 「library」 「trait」 「collection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ebidtech/collection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ebidtech/collection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ebidtech/collection 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
ADOdb is a PHP database abstraction layer library
Slimmed down concise interfaces and query builder for database queries and transactions which can be layered / decorated.
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
统计信息
- 总下载量: 122.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 27
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-11-28