thephpleague / uri-src

URI manipulation Library
https://uri.thephpleague.com
MIT License
30 stars 7 forks source link

Want to add the function of filling replacement templates in order. #2

Closed yinbug closed 2 years ago

yinbug commented 2 years ago

Feature Request

Q A
New Feature yes
BC Break no

Proposal

Want to add the function of filling replacement templates in order. It is better to support array

for example sprintf( 'http://xx.com/{id}/look/{pid}', $id, $pid);

nyamsprod commented 2 years ago

@yinbug What would this feature do that is not yet covered by

yinbug commented 2 years ago

The array of the official example is a key value pair. I want to leave out the key names and fill them in order. This is just an idea of mine.

Official example:

<?php
use League\Uri\UriTemplate;

$template = 'https://example.com/hotels/{hotel}/bookings/{booking}';

$params = ['booking' => '42', 'hotel' => 'Rest & Relax'];

$uriTemplate = new UriTemplate($template);
$uri = $uriTemplate->expand($params);

Fill in order:

<?php

use League\Uri\UriTemplate;

$template = 'https://example.com/hotels/{hotel}/bookings/{booking}';

$params = [ '42',  'Rest & Relax'];

$uriTemplate = new UriTemplate($template);
$uri = $uriTemplate->expand($params);
nyamsprod commented 2 years ago

Still I fail to see the added value. Why can't you just fill in the names of the arguments ?