PHPackages                             phpsanitization/phpsanitization - 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. phpsanitization/phpsanitization

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

phpsanitization/phpsanitization
===============================

Modern PHP Sanitization Library

v2.0.0(1y ago)18861↓32.1%4MITPHPPHP ^7.3 || ^8.0CI failing

Since Jan 14Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/farisc0de/PhpSanitization)[ Packagist](https://packagist.org/packages/phpsanitization/phpsanitization)[ Docs](https://github.com/farisc0de/PhpSanitization)[ GitHub Sponsors](https://github.com/farisc0de)[ Fund](https://ko-fi.com/fariscode)[ RSS](/packages/phpsanitization-phpsanitization/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (16)Used By (0)

 [![](https://camo.githubusercontent.com/f0aa9d3dd2cdc4c429d6082998ae470c9a23c4e41818cbb954cd01fc7efe3c56/68747470733a2f2f642e746f7034746f702e696f2f705f3138363261386b3165312e706e67)](https://camo.githubusercontent.com/f0aa9d3dd2cdc4c429d6082998ae470c9a23c4e41818cbb954cd01fc7efe3c56/68747470733a2f2f642e746f7034746f702e696f2f705f3138363261386b3165312e706e67)

PhpSanitization
===============

[](#phpsanitization)

[![](https://camo.githubusercontent.com/6807c19512680159c9ce0ee2b43833b0794ee39b1491eab872b421e982182847/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6661726973633064652f50687053616e6974697a6174696f6e)](https://camo.githubusercontent.com/6807c19512680159c9ce0ee2b43833b0794ee39b1491eab872b421e982182847/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6661726973633064652f50687053616e6974697a6174696f6e) [![](https://camo.githubusercontent.com/6190437dd87054c6d722ee39ae70f655a68d095f3a820a6dd3b33bb63fccbafd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6661726973633064652f50687053616e6974697a6174696f6e)](https://camo.githubusercontent.com/6190437dd87054c6d722ee39ae70f655a68d095f3a820a6dd3b33bb63fccbafd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6661726973633064652f50687053616e6974697a6174696f6e) [![](https://camo.githubusercontent.com/7610ab2db1312761a3ca0c45c4ce5bf73f05b8ebb2040298faefcb2ede6cd581/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6661726973633064652f50687053616e6974697a6174696f6e)](https://camo.githubusercontent.com/7610ab2db1312761a3ca0c45c4ce5bf73f05b8ebb2040298faefcb2ede6cd581/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6661726973633064652f50687053616e6974697a6174696f6e) [![](https://camo.githubusercontent.com/839a539c7d74c06768a99d16f497c4f3151a350ef3c401f976ca0411ae3e7243/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6661726973633064652f50687053616e6974697a6174696f6e)](https://camo.githubusercontent.com/839a539c7d74c06768a99d16f497c4f3151a350ef3c401f976ca0411ae3e7243/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f6661726973633064652f50687053616e6974697a6174696f6e)

About
-----

[](#about)

A modern, type-safe PHP sanitization library designed for security and efficiency.

PhpSanitization provides robust validation and sanitization capabilities to ensure your data is clean and safe. The library implements strict typing and leverages PHP 8's features for enhanced type safety and performance.

It can process strings, arrays (including deeply nested structures), and protect against various security threats like XSS and SQL injection.

Features
--------

[](#features)

1. **Strict Typing**: Full type declarations for all methods and parameters
2. **Enhanced Security**: Improved protections against XSS and SQL injection attacks
3. **Recursive Sanitization**: Deep cleaning of nested arrays and complex data structures
4. **Method Chaining**: Fluent interface for composing multiple operations
5. **Enhanced Email Validation**: DNS checking and custom provider validation
6. **Improved SQL Escaping**: Better protection using `strtr()` for more secure queries
7. **Comprehensive Documentation**: Complete examples for all features
8. **PHP 8 Features**: Utilizes union types and match expressions

Requirements
------------

[](#requirements)

1. PHP 8.0+
2. [Composer](https://getcomposer.org/)

Installation &amp; Usage
------------------------

[](#installation--usage)

### Installation

[](#installation)

```
$ composer require phpsanitization/phpsanitization
```

### Basic Setup

[](#basic-setup)

```
