Download the PHP package novabytes/odata-query-parser without Composer

On this page you can find all versions of the php package novabytes/odata-query-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package odata-query-parser

OData Query Parser for PHP

Latest Version on Packagist Test Status Code Style Status Total Downloads

A framework-agnostic OData 4 parser for PHP 8.2+. Parses query strings ($filter, $select, $expand, $orderby, $top, $skip, $count) and resource paths (/Products(1)/Category) into immutable AST objects.

Zero runtime dependencies.

Installation

Quick Start

You can also parse individual query options directly:

Supported Query Options

$filter

Full expression language with correct operator precedence:

30+ built-in functions:

Lambda expressions:

All literal types:

$select

$expand

$orderby

$top, $skip, $count

Parsed as part of QueryOptionParser::parse():

Resource Path Parsing

Parse OData resource paths (the URL path portion) into structured AST nodes:

AST Structure

Every parsed result is an immutable (readonly class) AST node. The $filter expression tree uses these node types:

Node Description
BinaryExpression left operator right (e.g. Price gt 100, A and B)
UnaryExpression operator operand (e.g. not expr, -5)
PropertyPath Dotted/slashed property reference (e.g. Address/City)
Literal Typed value: null, boolean, integer, decimal, string, GUID, date, etc.
FunctionCall Built-in function with arguments (e.g. contains(Name,'x'))
LambdaExpression collection/any(var:predicate) or collection/all(var:predicate)
ListExpression Parenthesized list for in operator (e.g. ('A','B','C'))

Visitor Pattern

Implement ExpressionVisitor to transform the AST into whatever you need:

A StringifyVisitor is included for round-tripping AST back to OData syntax:

Error Handling

All parse errors throw NovaBytes\OData\Exception\ParseException with position information:

OData 4 Support

System Query Options

Query Option Status Notes
$filter Supported Full expression language with correct operator precedence
$select Supported Property paths, wildcards (*), nested options
$expand Supported Navigation paths, nested query options ($filter, $select, $top, etc.)
$orderby Supported Expressions with asc/desc, multiple sort keys
$top Supported
$skip Supported
$count Supported Inline count (true/false)
$search Not yet Planned for a future release
$compute Not yet Planned for a future release
$apply Not yet Data aggregation extension, planned for a future release
$format Not yet
$index Not yet
$schemaversion Not yet
$skiptoken Not yet Opaque server-driven paging token
$deltatoken Not yet Opaque server-driven delta token

Filter Operators

Category Operators Status
Comparison eq, ne, gt, ge, lt, le Supported
Logical and, or, not Supported
Arithmetic add, sub, mul, div, divby, mod Supported
Membership in Supported
Enum flags has Supported
Grouping ( ) Supported
Lambda any, all Supported
Negation - (unary minus) Supported

Filter Functions

Category Functions Status
String contains, startswith, endswith, length, indexof, substring, tolower, toupper, trim, concat, matchesPattern Supported
Date/Time year, month, day, hour, minute, second, fractionalseconds, totalseconds, date, time, totaloffsetminutes, now, mindatetime, maxdatetime Supported
Math round, floor, ceiling Supported
Geo geo.distance, geo.length, geo.intersects Supported
Collection hassubset, hassubsequence Supported
Type cast, isof Supported

Literal Types

Type Example Status
Null null Supported
Boolean true, false Supported
Integer 42, -1 Supported
Decimal 3.14, 1.5e10 Supported
String 'Milk', 'O''Brien' Supported
GUID 01234567-89ab-cdef-0123-456789abcdef Supported
Date 2023-01-15 Supported
DateTimeOffset 2023-01-15T14:30:00Z Supported
TimeOfDay 14:30:00 Supported
Duration duration'P1DT2H30M' Supported
NaN / Infinity NaN, INF, -INF Supported
Binary binary'T0RhdGE=' Not yet
Enum Namespace.Color'Red' Not yet
Geography/Geometry geography'SRID=0;Point(...)' Not yet

Metadata

Generate OData metadata documents and OpenAPI specifications from entity type definitions.

Entity Types

Define your entity types using the metadata value objects:

EDM Type Resolver

Map database column types to OData EDM types:

CSDL Generation

Generate an OData v4 CSDL XML metadata document. When entity types have CRUD operations, capability annotations (InsertRestrictions, UpdateRestrictions, DeleteRestrictions) are included automatically:

OpenAPI Generation

Generate an OpenAPI 3.0 specification. CRUD operations are reflected as separate paths and schemas:

Design Decisions

Requirements

License

MIT


All versions of odata-query-parser with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package novabytes/odata-query-parser contains the following files

Loading the files please wait ...