DEV Community

loading...
Cover image for Hey there! Are you looking for PHP Sanitizers?

Hey there! Are you looking for PHP Sanitizers?

baalkrshna profile image Puneet Gopinath Updated on ・1 min read

Hooray! You got it!

Try this library in GitHub

GitHub logo PuneetGopinath / Sanitizers

Quickly Sanitize user data

Sanitizers logo

Welcome to BK Sanitizers (BKS)

Welcome

Quickly Sanitize user data

Sanitizers is also called as BK Sanitizers (Baal-Krshna Sanitizers)

Latest release: GitHub release (latest by date)
Info ⇒ BK Sanitizers is a Web Sanitizers written in php


See:
Sanitizers Docs »
Sanitizers Wiki »

Pages ⇒ Report bug(s)ReleasesRequest featureBlog



Twitter Join the chat at https://gitter.im/BaalKrshna/Sanitizers GitHub stars GitHub watchers

Table of contents

Quick Start 🚀

git clone https://github.com/PuneetGopinath/Sanitizers.git OR gh repo clone PuneetGopinath/Sanitizers

  • Installation 🔧

See INSTALL.md file for Installation guide.

  • Usage

Just include the file and Sanitize the user input.

  • Example Usage without composer autoload:
<?php
// Import classes
use Sanitizers\Sanitizers\Sanitizer
require "src/Sanitizers.php"
// passing `true` in Sanitize class enables exceptions
$sanitizer = new Sanitizer(true)
try {
    echo
Enter fullscreen mode Exit fullscreen mode

What is Sanitize ??

/ˈsanɪtʌɪz/ - to make something completely clean and free from bacteria.

In web development to sanitize(or sanitizing in web) means that you remove unsafe characters from the input.

Sanitize is a function to check (and remove) harmful data (which can harm the software) from user input.
Sanitizing user input is the most secure method of user input validation to strip out anything that is not on the whitelist.

When and why should I use Sanitizers ?

Whenever you store user's data, and if that data will be read/available to (unsuspecting) users, then you have to sanitize it.
See HTML sanitization in wikipedia

How can I clean user input ?

  • First, Sanitize
  • Then, Validate
  • Last, Escape output. Validating process image

Conclusion

If you sanitize user input then, you will be able to manage data properly, validate it, show it in a secure and reliable way.

It makes your web application trustworthy, so it must be one of your main goals from the beginning of your career as a web developer.

Discussion (0)

pic
Editor guide