{"id":21771145,"url":"https://github.com/initphp/input","last_synced_at":"2025-03-21T06:22:14.479Z","repository":{"id":49525587,"uuid":"470089471","full_name":"InitPHP/Input","owner":"InitPHP","description":"It is a simple library developed to retrieve user inputs by prioritizing or verifying.","archived":false,"fork":false,"pushed_at":"2023-02-24T13:04:47.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T03:13:46.962Z","etag":null,"topics":["input","input-validation","input-validator","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/InitPHP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-15T09:32:57.000Z","updated_at":"2022-04-04T08:20:05.000Z","dependencies_parsed_at":"2022-09-05T11:20:32.321Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Input","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FInput","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FInput/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FInput/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FInput/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Input/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244746791,"owners_count":20503264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["input","input-validation","input-validator","php"],"created_at":"2024-11-26T14:15:12.875Z","updated_at":"2025-03-21T06:22:14.455Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InitPHP Input\n\nIs a library for prioritizing or verifying Get, Post and Raw inputs.\n\n[![Latest Stable Version](http://poser.pugx.org/initphp/input/v)](https://packagist.org/packages/initphp/input) [![Total Downloads](http://poser.pugx.org/initphp/input/downloads)](https://packagist.org/packages/initphp/input) [![Latest Unstable Version](http://poser.pugx.org/initphp/input/v/unstable)](https://packagist.org/packages/initphp/input) [![License](http://poser.pugx.org/initphp/input/license)](https://packagist.org/packages/initphp/input) [![PHP Version Require](http://poser.pugx.org/initphp/input/require/php)](https://packagist.org/packages/initphp/input)\n\n\n## Requirements\n\n- PHP 7.2 or later\n- [InitPHP ParameterBag](https://github.com/InitPHP/ParameterBag)\n- [InitPHP Validation](https://github.com/InitPHP/Validation)\n\n## Installation\n\n```\ncomposer require initphp/input\n```\n\n## Usage\n\n**Example :**\n\n```php\nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Input\\Facade\\Inputs as Input;\n\n// echo isset($_GET['name']) ? $_GET['name'] : 'John';\necho Input::get('name', 'John');\n```\n\n**Example :**\n\n```php\nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Input\\Facade\\Inputs as Input;\n\n/**\n * if(isset($_GET['year']) \u0026\u0026 $_GET['year'] \u003e= 1970 \u0026\u0026 $_GET['year'] \u003c= 2070){\n *      $year = $_GET['year'];\n * }elseif(isset($_POST['year']) \u0026\u0026 $_POST['year'] \u003e= 1970 \u0026\u0026 $_POST['year'] \u003c= 2070){\n *      $year = $_POST['year'];\n * }else{\n *      $year = 2015;\n * }\n */\n$year = Input::getPost('year', 2015, ['range(1970...2070)']);\n```\n\n**Example :**\n\n```php\nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Input\\Facade\\Inputs as Input;\n\n/**\n * if(isset($_POST['password']) \u0026\u0026 isset($_POST['password_retype']) \u0026\u0026 !empty($_POST['password']) \u0026\u0026 $_POST['password'] == $_POST['password_retype']){\n *      $password = $_POST['password'];\n * }else{\n *      $password = null;\n * }\n */\n \n$password = Input::post('password', null, ['required', 'again(password_retype)'])\n```\n\n## Methods\n\n#### `Inputs::get()`\n\n```php\npublic function get(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::post()`\n\n```php\npublic function post(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::raw()`\n\nData from reading `php://input`.\n\n```php\npublic function raw(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n### Getting Input with Priority\n\n#### `Inputs::getPost()`\n\n`$_GET` -\u003e `$_POST`\n\n```php\npublic function getPost(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::getRaw()`\n\n`$_GET` -\u003e `php://input`\n\n```php\npublic function getRaw(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::getPostRaw()`\n\n`$_GET` -\u003e `$_POST` -\u003e `php://input`\n\n```php\npublic function getPostRaw(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::getRawPost()`\n\n`$_GET` -\u003e `php://input` -\u003e `$_POST`\n\n```php\npublic function getRawPost(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::postGet()`\n\n`$_POST` -\u003e `$_GET`\n\n```php\npublic function postGet(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::postRaw()`\n\n`$_POST` -\u003e `php://input`\n\n```php\npublic function postRaw(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::postGetRaw()`\n\n`$_POST` -\u003e `$_GET` -\u003e `php://input`\n\n```php\npublic function postGetRaw(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::postRawGet()`\n\n`$_POST` -\u003e `php://input` -\u003e `$_GET`\n\n```php\npublic function postRawGet(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::rawGet()`\n\n`php://input` -\u003e `$_GET`\n\n```php\npublic function rawGet(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::rawPost()`\n\n`php://input` -\u003e `$_POST`\n\n```php\npublic function rawPost(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::rawGetPost()`\n\n`php://input` -\u003e `$_GET` -\u003e `$_POST`\n\n```php\npublic function rawGetPost(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n#### `Inputs::rawPostGet()`\n\n`php://input` -\u003e `$_POST` -\u003e `$_GET`\n\n```php\npublic function rawPostGet(string $key, mixed $default = null, ?array $validation = null): mixed;\n```\n\n### Has it been declared?\n\nChecks to see if the requested entry has been declared.\n\n#### `Inputs::hasGet()`\n\nIt does something like `isset($_GET['key'])` , case-insensitively.\n\n```php\npublic function hasGet(string $key): bool;\n```\n\n#### `Inputs::hasPost()`\n\nIt does something like `isset($_POST['key'])` , case-insensitively.\n\n```php\npublic function hasPost(string $key): bool;\n```\n\n#### `Inputs::hasRaw()`\n\nCase-insensitively, it queries the body inputs for a key value.\n\n```php\npublic function hasRaw(string $key): bool;\n```\n\n## Credits\n\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) \u003c\u003cinfo@muhammetsafak.com.tr\u003e\u003e\n\n## License\n\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Finput","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Finput","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Finput/lists"}