innmind / url-template
Url template expansion processor
Installs: 19 612
Dependents: 5
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 1
pkg:composer/innmind/url-template
Requires
- php: ~8.4
- innmind/immutable: ~6.0
- innmind/url: ~5.0
Requires (Dev)
- innmind/black-box: ~6.5
- innmind/coding-standard: ~2.0
- innmind/static-analysis: ~1.3
This package is auto-updated.
Last update: 2026-01-25 13:44:27 UTC
README
RFC6570 implementation.
Installation
composer require innmind/url-template
Usage
use Innmind\UrlTemplate\Template; use Innmind\Immutable\Map; use Innmind\Url\Url; $url = Template::of('http://example.com/dictionary/{term:1}/{term}')->expand( Map::of(['term', 'dog']), ); $url instanceof Url; // true $url->toString(); // http://example.com/dictionary/d/dog $variables = Template::of('http://example.com/dictionary/{term:1}/{term}')->extract( Url::of('http://example.com/dictionary/d/dog') ); $variables; // Map<string, string> $variables->size(); // 1 $variables->get('term'); // dog
Important: variable extraction is not supported for list (ie {foo*} expression).