PHP code example of innmind / url-template
1. Go to this page and download the library: Download innmind/url-template library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
innmind / url-template example snippets
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