Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 64 | All time: 10,406 This week: 455 |
Version | License | PHP version | Categories | |||
ionizer 1.0.0 | MIT/X Consortium ... | 5 | HTTP, PHP 5, Validation |
Input filtering system used in CMS Airship, now available for use in any project. Requires PHP 7 or higher.
Ionizer is a structured input filtering system ideal for HTTP form data.
Get Composer, then run the following:
composer require paragonie/ionizer
<?php
use ParagonIE\Ionizer\GeneralFilterContainer;
use ParagonIE\Ionizer\Filter\{
StringFilter,
AllowList
};
// Define properties to filter:
$ic = new GeneralFilterContainer();
$ic->addFilter(
'username',
(new StringFilter())->setPattern('^[A-Za-z0-9_\-]{3,24}$')
)
->addFilter('passphrase', new StringFilter())
->addFilter(
'domain',
new AllowList('US-1', 'US-2', 'EU-1', 'EU-2')
);
// Invoke the filter container on the array to get the filtered result:
try {
// $post passed all of our filters.
$post = $ic($_POST);
} catch (\TypeError $ex) {
// Invalid data provided.
}
Ionizer can even specify structured input with some caveats.
<?php
use ParagonIE\Ionizer\GeneralFilterContainer;
use ParagonIE\Ionizer\Filter\{
IntFilter,
IntArrayFilter,
StringArrayFilter,
StringFilter
};
$ic = new GeneralFilterContainer();
// You can type entire arrays at once:
$ic->addFilter('numbers', new IntArrayFilter())
->addFilter('strings', new StringArrayFilter())
// You can also specify subkeys, separated by a period:
->addFilter('user.name', new StringFilter())
->addFilter('user.unixtime', new IntFilter());
$input = [
'numbers' => [1, 2, 3],
'strings' => ['a', 'b'],
'user' => [
'name' => 'test',
'unixtime' => time()
]
];
try {
$valid = $ic($input);
} catch (\TypeError $ex) {
}
If your company uses this library in their products or services, you may be interested in purchasing a support contract from Paragon Initiative Enterprises.
Files (32) |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
src (5 files, 2 directories) | ||||
tests (4 files, 1 directory) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml.dist | Data | Auxiliary data | ||
psalm.xml | Data | Auxiliary data | ||
README.md | Doc. | Read me |
Files (32) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Contract (2 files) | ||||
Filter (11 files, 1 directory) | ||||
GeneralFilterContainer.php | Class | Class source | ||
InputFilter.php | Class | Class source | ||
InputFilterContainer.php | Class | Class source | ||
InvalidDataException.php | Class | Class source | ||
Util.php | Class | Class source |
Files (32) | / | src | / | Contract |
File | Role | Description |
---|---|---|
FilterContainerInterface.php | Class | Class source |
FilterInterface.php | Class | Class source |
Files (32) | / | src | / | Filter |
File | Role | Description | ||
---|---|---|---|---|
Special (3 files) | ||||
AllowList.php | Class | Class source | ||
ArrayFilter.php | Class | Class source | ||
BoolArrayFilter.php | Class | Class source | ||
BoolFilter.php | Class | Class source | ||
FloatArrayFilter.php | Class | Class source | ||
FloatFilter.php | Class | Class source | ||
IntArrayFilter.php | Class | Class source | ||
IntFilter.php | Class | Class source | ||
StrictArrayFilter.php | Class | Class source | ||
StringArrayFilter.php | Class | Class source | ||
StringFilter.php | Class | Class source |
Files (32) | / | src | / | Filter | / | Special |
File | Role | Description |
---|---|---|
CreditCardNumberFilter.php | Class | Class source |
DateTimeFilter.php | Class | Class source |
EmailAddressFilter.php | Class | Class source |
Files (32) | / | tests |
File | Role | Description | ||
---|---|---|---|---|
Errata (1 file) | ||||
AllowListTest.php | Class | Class source | ||
ArrayFilterTest.php | Class | Class source | ||
FilterTest.php | Class | Class source | ||
SpecialTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.