Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bipiane/criteria-builder
Doctrine Criteria Builder from HTTP parameters in PHP
https://github.com/bipiane/criteria-builder
doctrine-orm query-builder query-params restful-api symfony
Last synced: 7 days ago
JSON representation
Doctrine Criteria Builder from HTTP parameters in PHP
- Host: GitHub
- URL: https://github.com/bipiane/criteria-builder
- Owner: bipiane
- Created: 2018-06-19T22:18:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-09T20:36:57.000Z (2 months ago)
- Last Synced: 2024-10-02T08:23:45.956Z (about 2 months ago)
- Topics: doctrine-orm, query-builder, query-params, restful-api, symfony
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Latest Stable Version](https://poser.pugx.org/bipiane/criteria-builder/v/stable)](https://packagist.org/packages/bipiane/criteria-builder)
[![Total Downloads](https://poser.pugx.org/bipiane/criteria-builder/downloads)](https://packagist.org/packages/bipiane/criteria-builder)
[![License](https://poser.pugx.org/bipiane/criteria-builder/license)](https://packagist.org/packages/bipiane/criteria-builder)Doctrine Criteria Builder from HTTP parameters in PHP
------------Installation
------------```bash
composer require bipiane/criteria-builder
```Example
------------```php
CriteriaDoctrine::CRITERIAS_NUMBER,
'name' => CriteriaDoctrine::CRITERIAS_STRING,
'lastname' => CriteriaDoctrine::CRITERIAS_STRING,
'city' => [
'id' => CriteriaDoctrine::CRITERIAS_NUMBER,
'name' => CriteriaDoctrine::CRITERIAS_STRING,
'state' => [
'id' => CriteriaDoctrine::CRITERIAS_NUMBER,
'name' => CriteriaDoctrine::CRITERIAS_STRING,
'code' => CriteriaDoctrine::CRITERIAS_STRING,
'country' => [
'id' => CriteriaDoctrine::CRITERIAS_NUMBER,
'name' => CriteriaDoctrine::CRITERIAS_STRING,
'enabled' => CriteriaDoctrine::CRITERIAS_BOOLEAN,
],
'enabled' => CriteriaDoctrine::CRITERIAS_BOOLEAN,
],
'enabled' => CriteriaDoctrine::CRITERIAS_BOOLEAN,
],
'enabled' => CriteriaDoctrine::CRITERIAS_BOOLEAN,
];try {
$qb = $this->getDoctrine()->getManager()
->getRepository('ModelBundle:User')
->createQueryBuilder('usr');$qb = CriteriaBuilder::fetchFromQuery(
$qb,
$request->query->all(),
$criteriaUser
);var_dump($qb->getQuery()->getArrayResult());
} catch (CriteriaException $e) {
}
// ...
}
```Testing
------------```
./vendor/bin/simple-phpunit
```