PHPackages                             mvanvu/php-filter - 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. mvanvu/php-filter

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

mvanvu/php-filter
=================

Php Input Filter package

1.0.5(5y ago)414921MITPHPPHP &gt;=5.5

Since Nov 20Pushed 5y ago2 watchersCompare

[ Source](https://github.com/mvanvu/php-filter)[ Packagist](https://packagist.org/packages/mvanvu/php-filter)[ Docs](https://github.com/mvanvu/php-filter)[ RSS](/packages/mvanvu-php-filter/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (7)Used By (1)

Php input filter
================

[](#php-input-filter)

Installation via Composer
-------------------------

[](#installation-via-composer)

```
{
	"require": {
		"mvanvu/php-filter": "~1.0"
	}
}
```

Alternatively, from the command line:

```
composer require mvanvu/php-filter
```

Usage
-----

[](#usage)

```
use MaiVu\Php\Filter;

// Syntax
Filter::clean($source, $type);

// Example
$source = 'Hello World!';

// Return 'Hello World!'
$filtered = Filter::clean($source, 'string');

// Source array
$source = [
	'Hello World!',
	'Hello VietNam!',
];

// Return ['Hello World!', 'Hello VietNam!']
$filtered = Filter::clean($source, 'string:array');

// Multi-type
$source = '  Hello World!  ';

// Return 'Hello World!'
$filtered = Filter::clean($source, ['string', 'trim']);
```

Add new custom rule
-------------------

[](#add-new-custom-rule)

```
use MaiVu\Php\Filter;
Filter::setRule('custom', function($value) {
    return $value . ' is filtered by a Closure';
});

$source = 'Hello World!';

// Return 'Hello World! is filtered by a Closure'
$filtered = Filter::clean($source, 'custom');

// The same above
Filter::clean($source, function($value) {
    return $value . ' is filtered by a Closure';
});
```

Extend filters
--------------

[](#extend-filters)

```
use MaiVu\Php\Filter;

class CustomFilter extends Filter
{
	public static function arrayInteger($value)
	{
		return static::clean($value, 'int:array');
	}
}

// Return '[1, 2, 3]'
echo '' . print_r(CustomFilter::clean(['1abc2', '2b', 3], 'arrayInteger'), true) . '';
```

Filter types
------------

[](#filter-types)

- int
- uint (unsigned int)
- float, double
- ufloat, udouble (unsigned float)
- boolean
- alphaNum (alpha number string)
- base64
- string (no HTML tags)
- email
- url
- slug (url alias without slash)
- path (url alias with slash)
- unset (return NULL value)
- jsonEncode
- jsonDecode
- yesNo, yes|no (return 'Y' or 'N')
- YES|NO (return 'YES' or 'NO')
- 1|0 (return 1 or 0)
- inputName (regex /\[^a-zA-Z0-9\_\]/)
- unique (array unique)
- basicHtml

Fallback default
----------------

[](#fallback-default)

```
if (isset(static::$rules[$type]))
    {
        $result = call_user_func_array(static::$rules[$type], [$value]);
    }
    elseif (is_callable($type))
    {
	    $result = call_user_func_array($type, [$value]);
    }
    elseif (function_exists($type))
    {
        $result = $type($value);
    }
    else
    {
        $result = $value;
    }
}
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

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

Recently: every ~112 days

Total

6

Last Release

1896d ago

PHP version history (2 changes)1.0PHP &gt;=5.4.0

1.0.2PHP &gt;=5.5

### Community

Maintainers

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

---

Top Contributors

[![mvanvu](https://avatars.githubusercontent.com/u/5796168?v=4)](https://github.com/mvanvu "mvanvu (10 commits)")

---

Tags

phpfilterinput

### Embed Badge

![Health badge](/badges/mvanvu-php-filter/health.svg)

```
[![Health](https://phpackages.com/badges/mvanvu-php-filter/health.svg)](https://phpackages.com/packages/mvanvu-php-filter)
```

###  Alternatives

[htmlawed/htmlawed

Official htmLawed PHP library for HTML filtering

401.1M9](/packages/htmlawed-htmlawed)[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)
