Download the PHP package initphp/input without Composer
On this page you can find all versions of the php package initphp/input. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download initphp/input
More information about initphp/input
Files in initphp/input
Informations about the package input
InitPHP Input
Read a single request value from the query string, the submitted form fields or the JSON request body — with configurable source priority and optional validation, behind one small API.
Features
- Three input sources behind one API:
get($_GET),post($_POST) andraw(the decoded JSONphp://inputbody). - Twelve priority helpers (
getPost,postRawGet, …) that read the sources in a defined order — the first source that contains the key wins. - Per-call validation powered by initphp/validation: a value that fails its rules yields the default.
- A safe JSON body reader: a scalar or malformed payload becomes an empty set instead of a fatal error.
- A static facade for ergonomic access, plus a fully injectable instance for testing and dependency injection.
- No shared static state between instances; PHPStan level max clean.
Requirements
- PHP 8.1 or later
- initphp/parameterbag
^2.0 - initphp/validation
^2.0 ext-json
Installation
Quick start
With the facade
With an instance
You can also hand the sources in explicitly — handy in tests or when the data does not come from the superglobals:
Reading from a single source
Each accessor returns the default (second argument, null when omitted)
if the key is absent. Keys are matched case-sensitively, just like
real HTTP query and body parameters.
Source priority
The priority helpers walk their sources in the order their name reads, left to right, and return the value of the first source that contains the key:
The full set: getPost, getRaw, getPostRaw, getRawPost, postGet,
postRaw, postGetRaw, postRawGet, rawGet, rawPost, rawGetPost,
rawPostGet.
Validation
Pass a list of validation rules as the third argument. When the resolved value fails, the default is returned:
The first source that owns the key is the one validated; a present but invalid value returns the default and does not fall through to the next source.
Presence checks
Documentation
Full developer documentation lives in docs/:
getting started, each source, the priority model, validation, the
facade, a complete API reference and an FAQ.
Testing
Credits
License
Released under the MIT License.
All versions of input with dependencies
ext-json Version *
initphp/parameterbag Version ^2.0
initphp/validation Version ^2.0