1. Go to this page and download the library: Download kphoen/rulerz library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kphoen / rulerz example snippets
$highRankFemalesRule = 'gender = "F" and points > 9000';
// a Doctrine QueryBuilder
$playersQb = $entityManager
->createQueryBuilder()
->select('p')
->from('Entity\Player', 'p');
// or an array of arrays
$playersArr = [
['pseudo' => 'Joe', 'gender' => 'M', 'points' => 2500],
['pseudo' => 'Moe', 'gender' => 'M', 'points' => 1230],
['pseudo' => 'Alice', 'gender' => 'F', 'points' => 9001],
];
// or an array of objects
$playersObj = [
new Player('Joe', 'M', 40, 2500),
new Player('Moe', 'M', 55, 1230),
new Player('Alice', 'F', 27, 9001),
];
// converts the rule in DQL and makes a single query to the DB
$highRankFemales = $rulerz->filter($playersQb, $highRankFemalesRule);
// filters the array of arrays
$highRankFemales = $rulerz->filter($playersArr, $highRankFemalesRule);
// filters the array of objects
$highRankFemales = $rulerz->filter($playersObj, $highRankFemalesRule);