PHPackages                             compwright/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. compwright/philter

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

compwright/philter
==================

A user-friendly interface for the PHP filter module

v1.0.1(today)06↑2400%MITPHPPHP ^8.5CI passing

Since Aug 14Pushed todayCompare

[ Source](https://github.com/compwright/philter)[ Packagist](https://packagist.org/packages/compwright/philter)[ RSS](/packages/compwright-philter/feed)WikiDiscussions master Synced today

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

compwright/philter
==================

[](#compwrightphilter)

[![PHP Composer](https://github.com/compwright/philter/actions/workflows/php.yml/badge.svg)](https://github.com/compwright/philter/actions/workflows/php.yml)

A user-friendly interface for the PHP filter module

- Easy to use type-hinted API with IDE support
- Sticks to a reasonable subset of functionality (FILTER\_VALIDATOR\_\*) and eschews deprecated and removed `filter` features
- Values fall back to null by default
- Supports named parameters
- All objects are readonly, inspectable, and idempotent
- High code quality that passes PHPStan level 9 and a full suite of unit tests

Supported Validators:

- Boolean
- Integer
- Float
- Regexp
- Email
- Url
- Domain
- Ip
- Mac
- Callback

Each one utilizes the corresponding `FILTER_VALIDATE_*` constant, with its supported options and flags.

Prerequisites
-------------

[](#prerequisites)

- PHP 8.5+
- PHP ext-filter module

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

[](#installation)

```
composer require --save compwright/philter

```

Example Usage
-------------

[](#example-usage)

```
use Compwright\Philter\Input;
use Compwright\Philter\Phactory;

// Args shown with defaults for demo purposes; omit if defaults are desired.
$ph = new Phactory(throwOnFailure: false, default: 'foo');

// Factory settings can be changed idempotently later
$ph2 = $ph->throwOnFailure(false)->setDefault(null);
assert($ph2 !== $ph1);

// Validators can be executed directly or on standard inputs
$boolean = $ph->boolean();
$featureFlag = $boolean('true');
$featureFlag = Input::get('feature-flag', $boolean);
$featureFlag = Input::post('feature-flag', $boolean);
$featureFlag = Input::cookie('feature-flag', $boolean);
$featureFlag = Input::server('feature-flag', $boolean);
$featureFlag = Input::env('feature-flag', $boolean);

// Validator-specific configuration
$integer = $ph->integer(min: -100, max: 100, allowOctal: true, allowHex: true);
assert($integer('42') === 42);
assert($integer('-27') === -27);
assert($integer('0b1') === 1); // binary
assert($integer('0o1') === 1); // octal
assert($integer('0x1') === 1); // hexadecimal
assert($integer(27.5) === null); // wrong type
assert($integer('142') === null); // out of range
```

License
-------

[](#license)

MIT License

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/138688?v=4)[Jonathon Hill](/maintainers/compwright)[@compwright](https://github.com/compwright)

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

ext-filterfilterfilter

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[clue/stream-filter

A simple and modern approach to stream filtering in PHP

1.7k281.7M9](/packages/clue-stream-filter)[laminas/laminas-filter

Programmatically filter and normalize data and files

9531.1M189](/packages/laminas-laminas-filter)[friendsofcake/search

CakePHP Search plugin using PRG pattern

1712.3M52](/packages/friendsofcake-search)[htmlawed/htmlawed

Official htmLawed PHP library for HTML filtering

411.3M19](/packages/htmlawed-htmlawed)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

46939.2k5](/packages/outl1ne-nova-multiselect-filter)[outl1ne/nova-detached-filters

This Laravel Nova package allows you to detach filters from the filter dropdown

63447.2k](/packages/outl1ne-nova-detached-filters)

PHPackages © 2026

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