complex-heart/criteria
Composer 安装命令:
composer require complex-heart/criteria
包简介
Small implementation of a filter criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface.
README 文档
README
Small implementation of a criteria pattern in PHP for Complex Heart SDK. Compose several filters using fluent interface.
Installation
Just install the package from Packagist using composer:
composer require complex-heart/criteria
Usage
Import the class and use the fluent interface:
namespace ComplexHeart\Domain\Criteria; // Match the users with status active and more than 7k followers and from Spain and France $g1 = FilterGroup::create() ->addFilterEqual('status', 1) ->addFilterGreaterThan('followers', 7000) ->addFilterIn('country', ['es', 'fr']); $criteria = Criteria::default() ->withFilterGroup($g1) ->withOrderBy('surname') ->withOrderType('asc') ->withPageLimit(25) ->withPageOffset(50); $users = $repository->match($criteria); // alternative, same as above $criteria = Criteria::default() ->withFilterGroup(FilterGroup::create() ->addFilterEqual('status', 1) ->addFilterGreaterThan('followers', 7000) ->addFilterIn('country', ['es', 'fr'])) ->withOrderBy('surname') ->withOrderType('asc') ->withPageLimit(25) ->withPageOffset(50); // In SQL, we may have something like: // WHERE status = 1 AND followers >= 700 AND country in ('es', 'fr') $users = $repository->match($criteria);
A FilterGroup is a set of filters or conditions that must match all together (AND). To match one group or another
(OR), just add more FilterGroup.
// Match articles with given term in title, or in tagline, or in content. $criteria = Criteria::default() ->withFilterGroup(FilterGroup::create()->addFilterContains('title', $term)) ->withFilterGroup(FilterGroup::create()->addFilterContains('tagline', $term)) ->withFilterGroup(FilterGroup::create()->addFilterContains('content', $term)) ->withOrderBy('created_at') ->withOrderType(Order::TYPE_ASC) ->withPageNumber(3);
complex-heart/criteria 适用场景与选型建议
complex-heart/criteria 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.76k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2022 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 complex-heart/criteria 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 complex-heart/criteria 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-05-16