Download the PHP package ozdemirrulass/uri-template without Composer
On this page you can find all versions of the php package ozdemirrulass/uri-template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ozdemirrulass/uri-template
More information about ozdemirrulass/uri-template
Files in ozdemirrulass/uri-template
Package uri-template
Short Description Enhanced PHP URI Template (RFC 6570) supports both expansion & extraction
License MIT
Informations about the package uri-template
PHP URI Template
This is a URI Template implementation in PHP based on RFC 6570 URI Template. In addition to URI expansion, it also supports URI extraction.
- This repository is strictly typed, cleaner version of rize/UriTemplate
- To ensure that the package functions properly, tests are duplicated exactly as they are.
Installation
Installation via composer
:
Usage
Expansion
A very simple usage (string expansion).
Ozdemirrulass\UriTemplate
supports all Expression Types
and Levels
specified by RFC6570.
/
Path segment expansion
Ozdemirrulass\UriTemplate
accepts base-uri
as a 1st argument and default params
as a 2nd argument. This is very useful when you're working with API endpoint.
Take a look at real world example.
Extraction
It also supports URI Extraction (extract all variables from URI). Let's take a look at the example.
Note that in the example above, result returned by extract
method has an extra keys named term:1
for prefix
modifier. This key was added just for our convenience to access prefix data.
strict
mode
Normally extract
method will try to extract vars from a uri even if it's partially matched. For example
With strict mode
, it will allow you to extract uri only when variables in template are fully matched with given uri.
Which is useful when you want to determine whether the given uri is matched against your template or not (in case you want to use it as routing service).
Array modifier %
By default, RFC 6570 only has 2 types of operators :
and *
. This %
array operator was added to the library because current spec can't handle array style query e.g. list[]=a
or key[user]=john
.
Example usage for %
modifier