PHPackages                             gl3n/http-query-string-filter-bundle - 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. gl3n/http-query-string-filter-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

gl3n/http-query-string-filter-bundle
====================================

Easy validation, casting and authorization of HTTP query string parameters

1.0.1(10y ago)68.2k1PHPPHP &gt;=5.4

Since Mar 31Pushed 7y ago2 watchersCompare

[ Source](https://github.com/gl3n/HttpQueryStringFilterBundle)[ Packagist](https://packagist.org/packages/gl3n/http-query-string-filter-bundle)[ RSS](/packages/gl3n-http-query-string-filter-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (6)Used By (0)

HttpQueryStringFilterBundle [![Build Status](https://camo.githubusercontent.com/4626414a90eb1a5b034ba90024d3f12454fc9ee049285ef1e824fa376e920de1/68747470733a2f2f7472617669732d63692e6f72672f676c336e2f487474705175657279537472696e6746696c74657242756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gl3n/HttpQueryStringFilterBundle)
===========================================================================================================================================================================================================================================================================================================================================================

[](#httpquerystringfilterbundle-)

Easy **validation**, **casting** and **authorization** of HTTP query string parameters.

1. Installation
---------------

[](#1-installation)

Install the bundle through composer, then add it to your `AppKernel.php` file :

```
$bundles = array(
    // ...
    new Gl3n\HttpQueryStringFilterBundle\Gl3nHttpQueryStringFilterBundle(),
);
```

2. Configuration
----------------

[](#2-configuration)

Here is a sample filters configuration :

```
gl3n_http_query_string_filter:
    filters:
        list:
            params:
                size: { type: string, reg_exp: '^s|m|l$', default: 's' }
        blog_post_list:
            include: [list]
            params:
                userId:  { type: integer }
                isDraft: { type: boolean, roles: [ROLE_ADMIN] }
                tagIds:  { type: integer, array: true, default: '[]' }
```

A filter has parameters (`params` node). It can also include other filters' parameters (`include` node).

### 2.1. Parameter configuration

[](#21-parameter-configuration)

Each parameter configuration has 6 options :

NameRequiredDescription`type`yes`string`, `boolean` or `integer` *(see below for detail)*`reg_exp`noThe regular expression to use for validation *(default depends on the parameter type)*`default`noDefault value *(will be casted depending on the parameter type)*`required`noBoolean that indicates whether the parameter is required *(default is false)*`array`noBoolean that indicates wheter expected parameter value is an array *(default is false)*`roles`noAn array of security roles allowed to use this parameter *(default is an empty array)*#### Parameter types

[](#parameter-types)

##### Definition

[](#definition)

A parameter type defines :

1. how the **value** (or the **values** in the case of a parameter configured as an array) will be **casted**,
2. the **default regular expression**.

##### Reference

[](#reference)

TypeCast toDefault reg exp**string**PHP string`^.+$`**boolean**PHP boolean``^true**integer**PHP integer`^\d+$`#### Default value in the case of array parameters

[](#default-value-in-the-case-of-array-parameters)

In this special case, default value is evaluated through Symfony **Expression Language** component. Then if the result in an array : each value is casted depending on the configured parameter type.

You can see an example of this case in the sample configuration above.

3. Usage
--------

[](#3-usage)

Add a query string filter on an action thanks to the **annotation** :

```
use Gl3n\HttpQueryStringFilterBundle\Annotation\HttpQueryStringFilter;
// ...

class BlogPostController
{
    /**
     * @HttpQueryStringFilter(name="blog_post_list")
     */
    public function listAction(Request $request)
    {
        // Now your request query is filtered
        $parameters = $request->query->all();
    }
}
```

4. How to write a custom parameter type
---------------------------------------

[](#4-how-to-write-a-custom-parameter-type)

Your parameter type class must implement `ParameterType\ParameterTypeInterface` with 2 methods :

1. `castValue($value)`
2. `getDefaultRegExp()`

Then declare it as a service, and add the tag `gl3n_http_query_string_filter.parameter_type` with the property `type`.

Here is an example of XML declaration :

```

```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% 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 ~658 days

Total

3

Last Release

2749d ago

Major Versions

1.0.1 → 2.x-dev2018-11-08

### Community

Maintainers

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

---

Top Contributors

[![gl3n](https://avatars.githubusercontent.com/u/965689?v=4)](https://github.com/gl3n "gl3n (21 commits)")[![nicolashWebikeo](https://avatars.githubusercontent.com/u/38078374?v=4)](https://github.com/nicolashWebikeo "nicolashWebikeo (1 commits)")

---

Tags

httpvalidationqueryauthorizationparametercastingcast

### Embed Badge

![Health badge](/badges/gl3n-http-query-string-filter-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/gl3n-http-query-string-filter-bundle/health.svg)](https://phpackages.com/packages/gl3n-http-query-string-filter-bundle)
```

###  Alternatives

[league/openapi-psr7-validator

Validate PSR-7 messages against OpenAPI (3.0.2) specifications expressed in YAML or JSON

55715.9M69](/packages/league-openapi-psr7-validator)[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43417.4M104](/packages/kevinrob-guzzle-cache-middleware)[crwlr/query-string

A library for convenient handling of query strings used in HTTP requests.

215.6M4](/packages/crwlr-query-string)[aphiria/aphiria

The Aphiria framework

1427.7k2](/packages/aphiria-aphiria)[bakame/http-structured-fields

A PHP library that parses, validates and serializes HTTP structured fields according to RFC9561 and RFC8941

442.6k4](/packages/bakame-http-structured-fields)

PHPackages © 2026

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