PHP code example of coolms / rql-doctrine

1. Go to this page and download the library: Download coolms/rql-doctrine 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/ */

    

coolms / rql-doctrine example snippets


$query  = (new RqlParser())->parse('filter=price gt 100&sort=-createdAt&limit=20');
$result = $visitor->apply($query, $repository->createQueryBuilder('n'), $context);

$result->items;       // the page of hydrated entities
$result->totalItems;  // total matching, ignoring pagination

// config/bundles.php
CoolMS\Rql\Doctrine\RqlDoctrineBundle::class => ['all' => true],

final class TagPredicateContributor implements FilterPredicateContributorInterface
{
    public function supports(string $rootClass, string $field): bool
    {
        return 'tags' === $field;
    }

    public function apply(/* ... */): void
    {
        // add your EXISTS subquery to the QueryBuilder
    }
}