PHPackages                             indgy/philter - 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. [Search &amp; Filtering](/categories/search)
4. /
5. indgy/philter

ActiveLibrary[Search &amp; Filtering](/categories/search)

indgy/philter
=============

A fluent input sanitiser without dependencies

0.1.5(3y ago)174MITPHPPHP ^7.1|^8.0

Since Jan 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/indgy/philter)[ Packagist](https://packagist.org/packages/indgy/philter)[ Docs](https://indgy.github.io/philter)[ RSS](/packages/indgy-philter/feed)WikiDiscussions main Synced 6d ago

READMEChangelog (1)DependenciesVersions (7)Used By (0)

[![Philter Logo](https://raw.githubusercontent.com/indgy/philter/main/docs/philter.svg)](https://raw.githubusercontent.com/indgy/philter/main/docs/philter.svg)

##### A PHP fluent input sanitiser.

[](#a-php-fluent-input-sanitiser)

Philter accepts untrusted input, passes it through some filters and returns it back to you. It is not a substitution for validation.

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

[](#installation)

Copy the `src/Philter.php` file to your project, or install using composer:

```
composer require indgy/philter
```

Getting started
---------------

[](#getting-started)

Create a new Philter instance passing in the untrusted input, then combine filters for the untrusted input to pass through and finally call [`toBool()`](https://indgy.github.io/philter/reference/#toBool), [`toFloat()`](https://indgy.github.io/philter/reference/#toFloat), [`toInt()`](https://indgy.github.io/philter/reference/#toInt) or [`toString()`](https://indgy.github.io/philter/reference/#toString) to get the filtered and now trusted input.

```
use \Indgy\Philter;

$f = new Philter($unsafe_input);
$str = $f->in(['safe','string','options'])
	->default('safe')
	->toString();
```

There is also a handy shortcut function to return a new Philter instance:

```
use function \Indgy\philter;

$str = philter($unsafe_input)
	->in(['safe','string','options'])
	->default('safe')
	->toString();
```

### Available filters

[](#available-filters)

[`allow(String $chars)`](https://indgy.github.io/philter/reference/#allow) - Allow only the characters in $chars

[`alpha()`](https://indgy.github.io/philter/reference/#alpha) - Allow only a-z

[`alphanum()`](https://indgy.github.io/philter/reference/#alphanum) - Allow only a-z and 0-9

[`ascii()`](https://indgy.github.io/philter/reference/#ascii) - Allow only ASCII chars (32-127), transliterating where possible

[`between(Int $min, Int $max)`](https://indgy.github.io/philter/reference/#between) - Allow values between min and max inclusive

[`contains(String $match)`](https://indgy.github.io/philter/reference/#contains) - Allow values containing $match

[`cut(Int $length)`](https://indgy.github.io/philter/reference/#cut) - Cut string to $length

[`digits()`](https://indgy.github.io/philter/reference/#digits) - Allow only 0-9

[`in(Array $items)`](https://indgy.github.io/philter/reference/#in) - Allow if in $items

[`max(Int $max)`](https://indgy.github.io/philter/reference/#max) - Allow only if less than or equal to $max

[`min(Int $min)`](https://indgy.github.io/philter/reference/#min) - Allow only if greater than or equal to $min

[`numeric()`](https://indgy.github.io/philter/reference/#numeric) - Allow only if numeric, e.g. currency string

[`trim()`](https://indgy.github.io/philter/reference/#trim) - Trim characters from beginning and end *(see also `ltrim()` and `rtrim()`)*

[`utf8()`](https://indgy.github.io/philter/reference/#utf8) - Convert to UTF-8 transliterating where possible

Refer to the [Reference](https://indgy.github.io/philter/reference/index.html) for more detail on the filters.

Custom filters
--------------

[](#custom-filters)

Define custom filters using the `apply()` method with a closure. The closure will be passed the current input value and expects it, or null to be returned.

```
philter('Here we go.. ')->apply(function($v) {
	// do your thing here
	$v = $v.=  'I was philtered';
	// always return $v or null
	return $v;
})->toString();
```

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

[](#documentation)

Refer to the [user guide](https://indgy.github.io/philter/index.html) or browse the [API ](https://indgy.github.io/philter/api/index.html).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~148 days

Recently: every ~129 days

Total

6

Last Release

1208d ago

PHP version history (2 changes)0.1.0PHP ^7.1

0.1.5PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65541311?v=4)[indgy](/maintainers/indgy)[@indgy](https://github.com/indgy)

---

Top Contributors

[![indgy](https://avatars.githubusercontent.com/u/65541311?v=4)](https://github.com/indgy "indgy (6 commits)")

---

Tags

inputphprequestsanitisersanitizersanitizerfilterinputsanitiser

### Embed Badge

![Health badge](/badges/indgy-philter/health.svg)

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

###  Alternatives

[clue/stream-filter

A simple and modern approach to stream filtering in PHP

1.7k261.7M7](/packages/clue-stream-filter)[htmlawed/htmlawed

Official htmLawed PHP library for HTML filtering

401.1M9](/packages/htmlawed-htmlawed)[laminas/laminas-filter

Programmatically filter and normalize data and files

9428.0M150](/packages/laminas-laminas-filter)[outl1ne/nova-input-filter

An input filter for Laravel Nova

24822.7k](/packages/outl1ne-nova-input-filter)[optimistdigital/nova-input-filter

An input filter for Laravel Nova

24550.6k2](/packages/optimistdigital-nova-input-filter)[digital-creative/nova-range-input-filter

A Laravel Nova range input filter.

18209.3k1](/packages/digital-creative-nova-range-input-filter)

PHPackages © 2026

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