fivelab/ruler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

fivelab/ruler

最新稳定版本:v1.3.1

Composer 安装命令:

composer require fivelab/ruler

包简介

Add rule for satisfy objects and generate queries based on specifications.

README 文档

README

 #StandWithUkraine 

Ruler

The library for apply the string rule to any query builders (Doctrine ORM, Elastica, etc...).

For start use ruler, you should create the target factories for all supported targets for you. After, you can create ruler and apply any rules:

<?php

use FiveLab\Component\Ruler\Ruler;
use FiveLab\Component\Ruler\Target\Targets;
use FiveLab\Component\Ruler\Target\DoctrineOrmTarget;
use FiveLab\Component\Ruler\Target\ElasticaTarget;

$targets = new Targets(
    new DoctrineOrmTarget(),
    new ElasticaTarget() 
);

$ruler = new Ruler($targets);

// Apply rules
$qb = $entityManager->createQueryBuilder()
    ->from('Product', 'products')
    ->select('products');

$ruler->apply($qb, 'category.key in (:categories) and enabled = :enabled and price > :price', [
    'categories' => ['cat1', 'cat2'], 
    'enabled' => true,
    'price' => 100
]);

Note: system auto-detect joins based on dot (.) for SQL targets and nested for document targets. If column contain dot (in ES as an example), you can escape dot via \ (money\.amount).

Development

For easy development you can use the Docker.

docker build -t ruler .
docker run -it -v $(pwd):/code --name ruler ruler bash

After success run and attach to container you must install vendors:

composer update

Before create the PR or merge into develop, please run next commands for validate code:

./bin/phpunit

./bin/phpcs --config-set show_warnings 0
./bin/phpcs --standard=vendor/escapestudios/symfony2-coding-standard/Symfony/ src/
./bin/phpcs --standard=tests/phpcs-ruleset.xml tests/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-13