Skip to content
/ Input Public

It is a simple library developed to retrieve user inputs by prioritizing or verifying.

License

Notifications You must be signed in to change notification settings

InitPHP/Input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InitPHP Input

Is a library for prioritizing or verifying Get, Post and Raw inputs.

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Requirements

Installation

composer require initphp/input

Usage

Example :

require_once "vendor/autoload.php";
use \InitPHP\Input\Facade\Inputs as Input;

// echo isset($_GET['name']) ? $_GET['name'] : 'John';
echo Input::get('name', 'John');

Example :

require_once "vendor/autoload.php";
use \InitPHP\Input\Facade\Inputs as Input;

/**
 * if(isset($_GET['year']) && $_GET['year'] >= 1970 && $_GET['year'] <= 2070){
 *      $year = $_GET['year'];
 * }elseif(isset($_POST['year']) && $_POST['year'] >= 1970 && $_POST['year'] <= 2070){
 *      $year = $_POST['year'];
 * }else{
 *      $year = 2015;
 * }
 */
$year = Input::getPost('year', 2015, ['range(1970...2070)']);

Example :

require_once "vendor/autoload.php";
use \InitPHP\Input\Facade\Inputs as Input;

/**
 * if(isset($_POST['password']) && isset($_POST['password_retype']) && !empty($_POST['password']) && $_POST['password'] == $_POST['password_retype']){
 *      $password = $_POST['password'];
 * }else{
 *      $password = null;
 * }
 */
 
$password = Input::post('password', null, ['required', 'again(password_retype)'])

Methods

Inputs::get()

public function get(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::post()

public function post(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::raw()

Data from reading php://input.

public function raw(string $key, mixed $default = null, ?array $validation = null): mixed;

Getting Input with Priority

Inputs::getPost()

$_GET -> $_POST

public function getPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::getRaw()

$_GET -> php://input

public function getRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::getPostRaw()

$_GET -> $_POST -> php://input

public function getPostRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::getRawPost()

$_GET -> php://input -> $_POST

public function getRawPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::postGet()

$_POST -> $_GET

public function postGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::postRaw()

$_POST -> php://input

public function postRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::postGetRaw()

$_POST -> $_GET -> php://input

public function postGetRaw(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::postRawGet()

$_POST -> php://input -> $_GET

public function postRawGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::rawGet()

php://input -> $_GET

public function rawGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::rawPost()

php://input -> $_POST

public function rawPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::rawGetPost()

php://input -> $_GET -> $_POST

public function rawGetPost(string $key, mixed $default = null, ?array $validation = null): mixed;

Inputs::rawPostGet()

php://input -> $_POST -> $_GET

public function rawPostGet(string $key, mixed $default = null, ?array $validation = null): mixed;

Has it been declared?

Checks to see if the requested entry has been declared.

Inputs::hasGet()

It does something like isset($_GET['key']) , case-insensitively.

public function hasGet(string $key): bool;

Inputs::hasPost()

It does something like isset($_POST['key']) , case-insensitively.

public function hasPost(string $key): bool;

Inputs::hasRaw()

Case-insensitively, it queries the body inputs for a key value.

public function hasRaw(string $key): bool;

Credits

License

Copyright © 2022 MIT License

About

It is a simple library developed to retrieve user inputs by prioritizing or verifying.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages