2017 © Pedro Peláez
 

library uri-template

RFC 6570 URI Template processor

image

uri-template/uri-template

RFC 6570 URI Template processor

  • Saturday, February 7, 2015
  • by mcrumley
  • Repository
  • 1 Watchers
  • 8 Stars
  • 19,532 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 5 % Grown

The README.md

UriTemplate

PHP RFC 6570 URI Template processor, (*1)

Installation

If you use Composer, just run, (*2)

composer require uri-template/uri-template

or add this to your composer.json, (*3)

"uri-template/uri-template": "~1.0"

If you do not use composer, just copy the files into your project's lib folder., (*4)

Reqirements

UriTemplate requires PHP 5.3 or greater, (*5)

Examples

<?php
use UriTemplate\Processor;
$url = new Processor('http://github.com{/project}', array(
    'project' => array('mcrumley', 'uritemplate')
));
echo $url->process();
// prints http://github.com/mcrumley/uritemplate

// or
$url = new Processor();
$url->setTemplate('http://github.com{/project}');
$url->setData(array('project' => array('mcrumley', 'uritemplate')));
echo $url->process();
// prints http://github.com/mcrumley/uritemplate

Static Class

There is also a static class that does processes templates without creating an object., (*6)

<?php
use UriTemplate\UriTemplate;
echo UriTemplate::expand('http://github.com{/project}', array(
    'project' => array('mcrumley', 'uritemplate')
));
// prints http://github.com/mcrumley/uritemplate

The static class has additional methods for getting information about the template, (*7)

echo implode(', ', (UriTemplate::getVariables('http://{.url}{/project}')));
// prints url, project

$templateErrors = UriTemplate::getErrors('http://{.url:error}{=project}'));
echo implode(', ', $templateErrors);
// prints Malformed varspec: ".url:error", Malformed varspec: "=project"

Tests

Each version is tested against all samples available at https://github.com/uri-templates/uritemplate-test., (*8)

License

© Michael Crumley, (*9)

MIT licensed. For the full copyright and license information, please view the LICENSE file distributed with the source code., (*10)

The Versions

07/02 2015

dev-master

9999999-dev http://github.com/mcrumley/uritemplate

RFC 6570 URI Template processor

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

template url uri

07/02 2015

v1.0.0

1.0.0.0 http://github.com/mcrumley/uritemplate

RFC 6570 URI Template processor

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

template url uri