定制 consolidation/filter-via-dot-access-data 二次开发

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

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

consolidation/filter-via-dot-access-data

Composer 安装命令:

composer require consolidation/filter-via-dot-access-data

包简介

This project uses dflydev/dot-access-data to provide simple output filtering for applications built with annotated-command / Robo.

README 文档

README

This project uses dflydev/dot-access-data to provide simple output filtering for applications built with annotated-command / Robo.

ci scrutinizer codecov License

Overview

This project provides a simple logic expression evaluator which can be used in conjunction with dflydev/dot-access-data to filter out results of the sort that you might return as a RowsOfFields object, or a nested yaml/json array.

API

To use this filter in your annotated-commands-aware application (see g1a/starter), ensure that the filter hooks are registered with

$commandClasses = [ 
    \Consolidation\Filter\Hooks\FilterHooks::class,   // Filter hooks
    \MyApp\Commands\MyCommands::class,                // Commandfiles for your application
];
$runner = new \Robo\Runner($commandClasses);

Then, any command that returns RowsOfFields data (see consolidation/output-formatters) or an array may utilize the output filter feature simply by annotating its command method with @filter-output.

    /**
     * Convert a command from one format to another, potentially with filtering.
     *
     * @command example
     * @filter-output
     * @return array
     */
    public function example(array $parameters, $options = ['format' => 'yaml'])
    {
        return $this->doSomething($parameters);
    }

Annotating a command in this way will automaitically attach a --filter[=FILTER] option to the command. The output of the command may then be filtered by providing a simple expression:

$ mycmd example p1 p2 --filter='color=red'

A contains comparison may be done via the *= operator:

$ mycmd example p1 p2 --filter='color*=red'

And, finally, regex compares are also available via ~=:

$ mycmd example p1 p2 --filter='color~=#^red.*#'

The filter decides whether to include or exclude each top-level element based on the result of evaluating the provided expression on each element.

  • Nested data elements may be tested, e.g. via attributes.color=red
  • Simple boolean logic may be used, e.g. color=red&&shape=round

Parenthesis are not supported.

Getting Started

To build this project locally, follow the steps below.

Prerequisites

Install dependencies:

composer install

If you wish to build the phar for this project, install the box phar builder via:

composer phar:install-tools

Running the tests

The test suite may be run locally by way of some simple composer scripts:

Test Command
Run all tests composer test
PHPUnit tests composer unit
PHP linter composer lint
Code style composer cs
Fix style errors composer cbf

Deployment

Deploy by the following procedure:

  • Edit the VERSION file to contain the version to release, and commit the change.
  • Run composer release

Contributing

Please read CONTRIBUTING.md for details on the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the releases page.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

consolidation/filter-via-dot-access-data 适用场景与选型建议

consolidation/filter-via-dot-access-data 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49.53M 次下载、GitHub Stars 达 46, 最近一次更新时间为 2018 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 consolidation/filter-via-dot-access-data 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 49.53M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 46
  • 点击次数: 29
  • 依赖项目数: 7
  • 推荐数: 0

GitHub 信息

  • Stars: 46
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-19