|
1 | 1 | # PHP input class
|
2 | 2 | ## This package can process the current HTTP request values.
|
3 | 3 |
|
| 4 | +## Requirement |
| 5 | +1. PHP |
| 6 | +2. Composer |
| 7 | + |
| 8 | +## Installation |
| 9 | +Installing this package is very simple, first ensure you have the right PHP version and composer installed then in your terminal/(command prompt) run: `composer require lablnet/input` |
| 10 | + |
| 11 | +## Dependencies |
| 12 | +This class use `[lablnet/http-client](https://packagist.org/packages/lablnet/http-client)` library. |
| 13 | + |
4 | 14 | ## Feature
|
5 | 15 |
|
6 |
| - 1. Supported method get,post,put |
7 |
| - 2. Clean input method |
8 |
| - 3. check whether request is ajax or not |
9 |
| - 4. Wordwrap |
10 |
| - 5. check whether form submit or not |
11 |
| - 6. Restore line breaks method |
| 16 | + 1. Supported method get,post,put,patch,delete,files,others. |
| 17 | + 2. Clean input method(clean XSS attack/sanitize input). |
| 18 | + 3. Determine whether request is ajax or not. |
| 19 | + 4. Restore line breaks method. |
12 | 20 |
|
13 | 21 | # Description
|
14 |
| -It can access the HTTP request values and return them in a more convinient way to the application. |
15 |
| -Currently it can check the input values when using the GET, POST, PUT parameters, filter the parameter values, check whether request is sent by a browser using AJAX, word wrap parameter values, check whether |
| 22 | +It can access the HTTP request values and return them in a more convenient way to the application. |
| 23 | +Currently it can check the input values when using the GET, POST, PUT, PATCH, DELETE, FILES etc parameters, filter the parameter values, check whether request is sent by a browser using AJAX, word wrap parameter values, check whether |
16 | 24 | the request is a form submission, fix parameter value line breaks.
|
17 | 25 |
|
18 |
| -## TODO |
19 |
| -Add method for emojies convertor |
| 26 | +> This class provide helpers functions for easily use of class. |
| 27 | +
|
| 28 | +## Input |
| 29 | +You can get input by calling `input` helpers or `Input::input` method |
| 30 | +```php |
| 31 | +require_once "../vendor/autoload.php"; |
| 32 | +$username = input('username'); |
| 33 | +``` |
| 34 | +```php |
| 35 | +//in OOP style |
| 36 | +use Lablnet\Input; |
| 37 | +require_once "../vendor/autoload.php"; |
| 38 | +$username = Input::input('username'); |
| 39 | +``` |
| 40 | + |
| 41 | +## Escape |
| 42 | +You can escape input by calling `escape` helpers or `Input::escape` method |
| 43 | +```php |
| 44 | +require_once "../vendor/autoload.php"; |
| 45 | +$username = escape(input('username')); |
| 46 | +``` |
| 47 | +```php |
| 48 | +//in OOP style |
| 49 | +use Lablnet\Input; |
| 50 | +require_once "../vendor/autoload.php"; |
| 51 | +$username = Input::clean(Input::input('username')); |
| 52 | +``` |
| 53 | + |
| 54 | +## Determine whether request is ajax/xhr? |
| 55 | +You can determine current request by calling `is_ajax` helpers or `Input::isAjax` method |
| 56 | +```php |
| 57 | +require_once "../vendor/autoload.php"; |
| 58 | +if (is_ajax('name')) { |
| 59 | + //ajax |
| 60 | +} |
| 61 | +``` |
| 62 | +```php |
| 63 | +//in OOP style |
| 64 | +use Lablnet\Input; |
| 65 | +require_once "../vendor/autoload.php"; |
| 66 | +if (Input::isAjax('name')) { |
| 67 | + //ajax |
| 68 | +} |
| 69 | +``` |
20 | 70 |
|
21 |
| -# Simple Example |
22 |
| -## for more detail see index.php |
23 |
| - <?php |
24 |
| - require_once 'init.php'; |
25 |
| - echo InPut::Input('q'); |
26 |
| - ?> |
27 |
| - <form action='' method='post'> |
28 |
| - <input type='text' name='q' ?> |
29 |
| - </form> |
| 71 | +## Restore line breaks |
| 72 | +You can restore line breaks by calling `restore_line_break` helpers or `Input::restoreLineBreaks` method |
| 73 | +```php |
| 74 | +require_once "../vendor/autoload.php"; |
| 75 | +$comment = restore_line_break(escape(input('username'))); |
| 76 | +``` |
| 77 | +```php |
| 78 | +//in OOP style |
| 79 | +use Lablnet\Input; |
| 80 | +require_once "../vendor/autoload.php"; |
| 81 | +$comment = Input::restoreLineBreaks(Input::clean(Input::input('username'))); |
| 82 | +``` |
30 | 83 |
|
31 |
| - |
|
0 commit comments