The League of Extraordinary Packages

Our Packages:

Presented by The League of Extraordinary Packages

Getting Started


The Components

Url is end of life. We strongly encourage you to use League\Uri instead.

The Query class

This class is a multiple values component class and manages the URL query component. It implementing the League\Url\Components\QueryInterface.

This interface adds the following method:


Updates the component data;

On output, the query string is encoded following the RFC 3986

Example using the League\Url\Components\Query object:


use League\Url\Components\Query;

$query = new Query('foo=bar');
$query['baz'] = 'troll';
$query['toto'] = 'le heros';
foreach ($query as $offset => $value) {
	echo "$offset => $value".PHP_EOL;
// will echo
// foo => bar
// baz => troll
// toto => le%20heros

$query->modify(array('foo' => 'baz', 'toto' => null));
//by setting toto to null
//you remove the toto argument from the query_string
//you can get the same result by issuing

$found = $query->keys('troll');
//$found equals array(0 => 'baz')

echo count($query); //will return 2;