PHPackages                             bentools/querystring - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. bentools/querystring

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bentools/querystring
====================

Query String manipulation library. PHP 7.1+. No dependency, immutable, PSR-7 compliant.

1.3.1(1y ago)1339.5k↓43.3%7MITPHPPHP &gt;=7.1CI failing

Since Nov 15Pushed 1y ago2 watchersCompare

[ Source](https://github.com/bpolaszek/querystring)[ Packagist](https://packagist.org/packages/bentools/querystring)[ RSS](/packages/bentools-querystring/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (10)Used By (7)

[![Latest Stable Version](https://camo.githubusercontent.com/063929c7fec2a67191c2fc18c675def1e90154e8c8d87bcfa06cf424b7686253/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f7175657279737472696e672f762f737461626c65)](https://packagist.org/packages/bentools/querystring)[![License](https://camo.githubusercontent.com/6a4df15f4471851ddab480955df35e9cd74db0a77c845c8e017625141738b75f/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f7175657279737472696e672f6c6963656e7365)](https://packagist.org/packages/bentools/querystring)[![CI Workflow](https://github.com/bpolaszek/querystring/actions/workflows/ci-workflow.yml/badge.svg)](https://github.com/bpolaszek/querystring/actions/workflows/ci-workflow.yml)[![Coverage](https://camo.githubusercontent.com/903df2c5c0aacb1ae64a7c490709cf91f560a6d509dd33091000294c2100da1b/68747470733a2f2f636f6465636f762e696f2f67682f62706f6c61737a656b2f7175657279737472696e672f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d39415851554859315237)](https://codecov.io/gh/bpolaszek/querystring)[![Quality Score](https://camo.githubusercontent.com/05374ba6a66bafc642a77a8613337f27da403677a08f08a91b22b1952001f84c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f62706f6c61737a656b2f7175657279737472696e672e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bpolaszek/querystring)[![Total Downloads](https://camo.githubusercontent.com/921cf32e77ab2b060d4bba3878a258bee41ec0e02011ad367785892e8c796262/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f7175657279737472696e672f646f776e6c6f616473)](https://packagist.org/packages/bentools/querystring)

QueryString
===========

[](#querystring)

A lightweight, object-oriented, Query String manipulation library.

Why?
----

[](#why)

Because I needed an intuitive way to add or remove parameters from a query string, in any project.

Oh, and, I also wanted that `['foos' => ['foo', 'bar']]` resolved to `foos[]=foo&foos[]=bar` instead of `foos[0]=foo&foos[1]=bar`, unlike many libraries do.

Thanks to object-oriented design, you can define the way query strings are [parsed](doc/Instantiation.md) and [rendered](doc/RenderAsString.md#change-renderer).

Usage
-----

[](#usage)

Simple as that:

```
require_once __DIR__ . '/vendor/autoload.php';

use function BenTools\QueryString\query_string;

$qs = query_string(
    'foo=bar&baz=bat'
);
$qs = $qs->withParam('foo', 'foofoo')
    ->withoutParam('baz')
    ->withParam('ho', 'hi');

print_r($qs->getParams());
/* Array
(
    [foo] => foofoo
    [ho] => hi
) */

print $qs; // foo=foofoo&ho=hi
```

Documentation
-------------

[](#documentation)

[Instantiation / Parsing](doc/Instantiation.md)

[Manipulate parameters](doc/ManipulateParameters.md)

[Render as string](doc/RenderAsString.md)

Installation
------------

[](#installation)

PHP 7.1+ is required.

> composer require bentools/querystring:^1.0

Tests
-----

[](#tests)

> ./vendor/bin/phpunit

License
-------

[](#license)

MIT

See also
--------

[](#see-also)

[bentools/uri-factory](https://github.com/bpolaszek/uri-factory) - A PSR-7 `UriInterface` factory based on your own dependencies.

[bentools/pager](https://github.com/bpolaszek/bentools-pager) - A simple, object oriented Pager.

[bentools/where](https://github.com/bpolaszek/where) - A framework-agnostic fluent, immutable, SQL query builder.

[bentools/picker](https://github.com/bpolaszek/picker) - Pick a random item from an array, with weight management.

[bentools/psr7-request-matcher](https://github.com/bpolaszek/psr7-request-matcher) - A PSR-7 request matcher interface.

[bentools/cartesian-product](https://github.com/bpolaszek/cartesian-product) - Generate all possible combinations from a multidimensionnal array.

[bentools/string-combinations](https://github.com/bpolaszek/string-combinations) - A string combinations generator.

[bentools/flatten-iterator](https://github.com/bpolaszek/flatten-iterator) - An iterator that flattens multiple iterators or arrays.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~367 days

Recently: every ~377 days

Total

8

Last Release

529d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/acdd1a8ee0e657ddd06cf11f98a32100ef7121afb8aa270a5b295f5c29c038b3?d=identicon)[bpolaszek](/maintainers/bpolaszek)

---

Top Contributors

[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (21 commits)")

---

Tags

immutablelightweightphpphp7php71psr-7querystringuriurlpsr-7urluriquerystringquery-stringpsr7

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bentools-querystring/health.svg)

```
[![Health](https://phpackages.com/badges/bentools-querystring/health.svg)](https://phpackages.com/packages/bentools-querystring)
```

###  Alternatives

[league/uri

URI manipulation library

1.1k206.4M277](/packages/league-uri)[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

536204.9M23](/packages/league-uri-interfaces)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.0B3.2k](/packages/guzzlehttp-psr7)[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k789.4M1.8k](/packages/symfony-routing)[crwlr/url

Swiss Army knife for URLs.

11073.3k3](/packages/crwlr-url)[pdeans/http

PSR-7 cURL HTTP client with support for PSR-17 HTTP factories.

1466.2k3](/packages/pdeans-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
