PHPackages                             grithin/phpinput - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. grithin/phpinput

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

grithin/phpinput
================

PHP Tools for handling input.

3.0.0(10y ago)026Apache-2.0PHPPHP &gt;=5.5.9

Since Oct 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/grithin/phpinput)[ Packagist](https://packagist.org/packages/grithin/phpinput)[ Docs](http://devtools.grithin.com)[ RSS](/packages/grithin-phpinput/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Grithin's PHP Input Tools
=========================

[](#grithins-php-input-tools)

Purpose
-------

[](#purpose)

Provide a succinct way for common filtering and validating of input

See the Input class inline documentation

Brief
-----

[](#brief)

Rules is an array of rules whos keys map the keys of the input

Rules are parsed in the order provided

A rule consists of steps

Each rule can be an array of steps or a string of steps separated with ','

Every step consists of at most three parts

- prefix
- handler
- parameters

The rule looks like one of the following

- `handler|param1;param2;param3, handler, handler`
- `['handler|param1;param2;param3', handler, handler]`
- `[[handler, param1, param2, param2], handler, handler]`
- `[[[prefix, callback], param1, param2, param2], handler, handler]`Notice, as a string, parameters are separated with ";"

The prefix can be some combination of the following

- "!" to break on error with no more rules for that field
- "!!" to break on error with no more rules for any field
- "?" to indicate the validation is optional, and not to throw an error (useful when combined with '!' =&gt; '?!v.filled,email')
- "~" to indicate if the validation does not fail, then there was an error
- "&amp;" to indicate code should break if there were any previous errors on that field. This moves around the responsibility of ending on error, which is sometimes desirable with prefixed validations : `prefixed_validation.concat ['&validation2',...]`
- "&amp;&amp;" to indicate code should break if there were any previous errors on any field in the validate run

The handler can be one of the following

- "f.name" or "filter.name" where 'name' is a method of \\Grithin\\Filter
- "v.name" or "validate.name" where 'name' is a method of \\Grithin\\Validate
- "g.name" or "global.name" where name is a global user function
- "l.instance.name" or "local.instance.name" where "instance" is an instance name of $this-&gt;localInstances and "name" is the method
- "class.method" where "class" is the name of a class and "method" is a name of a static method on that class
- An actual callback-able value. For instance \['\\Grithin\\Filter','trim'\]

Example
-------

[](#example)

```
use \Grithin\Input;

$in = ['bob'=>'sucks'];
$input = new Input(['in'=>$in]);

#validate that the bob value is a float
$rules = ['bob'=>'v.isFloat'];

if($input->handle($rules)){
	die("Yay!");
}else{
	echo 'uh oh...';
	\Grithin\Debug::quit($input->errors);
}
/*
uh oh...

[base:index.php:19] 1: [
	0 : [
		'type' : 'isFloat'
		'fields' : [
			0 : 'bob'
		]
	]
]
*/
```

```
use \Grithin\Input;

$passingInput = [];

$passingInput[1] = [
		'phone'=>'my phone number is (555)   555-5555.',
		'appointment_time' => 'August 8, 2020',
		'comment' => '    bob is a crazy    '
	];
$passingInput[2] = [
		'phone'=>'my phone number is (555)   555-5555.',
		'comment' => '    bob is a crazy    '
	];

#validate that the bob value is a float
$rules = [
		'phone'=>'v.phone',
		'appointment_time'=>'?!v.filled,v.date,f.datetime', #< '?' means optional, '!' means stop of not validated
		'comment' => 'f.trim'
	];

$input = new Input(['in'=>$passingInput[1]]);
$input->handle($rules);
\Grithin\Debug::out($input->in);
/*
[base:index.php:34] 1: [
	'phone' : '5555555555'
	'appointment_time' : '2020-08-08 00:00:00'
	'comment' : 'bob is a crazy'
]*/

$input = new Input(['in'=>$passingInput[2]]);
$input->handle($rules);
\Grithin\Debug::out($input->in);
/*
[base:index.php:45] 2: [
	'phone' : '5555555555'
	'comment' : 'bob is a crazy'
]
*/
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Total

4

Last Release

3650d ago

Major Versions

v1.1.0 → 3.0.02016-07-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/4543facab3c88d548b98d8472b532faf7bcd00555cc47c0dc808d935f8d3d73f?d=identicon)[grithin](/maintainers/grithin)

---

Top Contributors

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

---

Tags

php input tools

### Embed Badge

![Health badge](/badges/grithin-phpinput/health.svg)

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

###  Alternatives

[botman/driver-web

Web driver for BotMan

86690.6k7](/packages/botman-driver-web)[laminas/laminas-navigation

Manage trees of pointers to web pages in order to build navigation systems

162.7M74](/packages/laminas-laminas-navigation)[elfsundae/laravel-gravatar

The easiest way to generate Gravatar avatar URL.

388.9k](/packages/elfsundae-laravel-gravatar)[judev/php-intervaltree

Interval Tree implementation in PHP

1141.8k1](/packages/judev-php-intervaltree)

PHPackages © 2026

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