Skip to content

Geraint/odata-query-builder

Repository files navigation

OData Query Builder for PHP

Build and Test

This is basic query builder with a fluent interface for constructing OData URL's.

It is not intended to be a full implementation but, if your needs are modest, then it could be a good fit for your project.

Install

composer require geraint/odata-query-builder:dev-master

Example

<?php

use ODataQueryBuilder\ODataQueryBuilder;

$serviceRootUrl = 'https://services.odata.org/V4/TripPinService/';
$resourcePath = 'People';
$builder = new ODataQueryBuilder($serviceRootUrl, $resourcePath);
$query = $builder
    ->filter("FirstName eq 'Scott'")
    ->select('UserName, LastName, FirstName')
    ->orderBy('LastName asc')
    ->format('json')
    ->build();

$query should now contain the following:

https://services.odata.org/V4/TripPinService/People?$filter=FirstName%20eq%20%27Scott%27&$select=UserName%2C%20LastName%2C%20FirstName&$orderby=LastName%20asc&$format=json

See doc/methods.md for more info.

License

See the LICENSE file for license rights and limitations (GNU GPLv3).

Alternatives

About

A very simple OData Query Builder for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages