Download the PHP package kdubuc/query-string-parser without Composer
On this page you can find all versions of the php package kdubuc/query-string-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kdubuc/query-string-parser
More information about kdubuc/query-string-parser
Files in kdubuc/query-string-parser
Package query-string-parser
Short Description PSR15 Query String Parser
License CECILL-2.1
Homepage https://github.com/kdubuc/query-string-parser
Informations about the package query-string-parser
Query String Parser
PSR-15 middleware that parses query strings following the OpenAPI 3.0 serialization spec.
PHP's parse_str() silently overwrites duplicate keys (?id=1&id=2 → only id=2 survives). This middleware fixes that and adds full support for OpenAPI serialization styles.
Note: We do not rewrite the URI. The original query, headers, paths, cookies, and other params are preserved in the request's attributes, we only set the parsed query parameters. This is important because some middleware may rely on the raw URI for logging, HMAC signature validation, cache-key generation, etc.
Install
Usage
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$urlEncoding |
int\|false |
PHP_QUERY_RFC1738 |
Decoding applied to keys and values. PHP_QUERY_RFC1738 (+ → space), PHP_QUERY_RFC3986 (%20 only), or false (no decoding). |
$style |
string |
'form' |
OpenAPI serialization style. See table below. |
$explode |
bool |
true |
When true, each value is a distinct key=value pair. When false, multiple values are packed into a single parameter using a delimiter. |
Serialization styles
Follows the OpenAPI 3.0 query parameter serialization rules:
style |
explode |
Array id = [3,4,5] |
Object id = {role:admin, firstName:Alex} |
|---|---|---|---|
form (default) |
true (default) |
?id=3&id=4&id=5 |
?role=admin&firstName=Alex |
form |
false |
?id=3,4,5 |
?id=role,admin,firstName,Alex |
spaceDelimited |
true |
?id=3&id=4&id=5 |
— |
spaceDelimited |
false |
?id=3%204%205 |
— |
pipeDelimited |
true |
?id=3&id=4&id=5 |
— |
pipeDelimited |
false |
?id=3\|4\|5 |
— |
deepObject |
true |
— | ?id[role]=admin&id[firstName]=Alex |
Testing
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The CeCILL-B License. Please see License File for more information.
All versions of query-string-parser with dependencies
psr/http-message Version ^1.0
psr/http-server-middleware Version ^1.0
guzzlehttp/psr7 Version ^1.5 || ^2.0