Encapsulated user input.





Fund package maintenance!

v1.2.3 2023-05-02 17:16 UTC


By default, PHP stores all user input in global arrays ($_GET, $_POST, and $_FILES) available for reading and modification in any code, including third party libraries.

This library wraps user input in objects that promote encapsulation, allowing functions to be passed only the user input they require, rather than having unmitigated read/write access to everything.

Type-safe functions allow more predictable functionality, such as $input->getFileUpload("photo"), $input->getDateTime("date-of-birth"), and $input->getMultipleString("pizza-topping").

PHP.Gt/Input build status PHP.Gt/Input code quality PHP.Gt/Input code coverage PHP.Gt/Input latest release PHP.G/Input documentation

Example usage

<form method="post">
	<h1>User Profile</h1>
		<span>Your name</span>
		<input name="name" placeholder="e.g. Eugene Kaspersky" required />	

		<input type="number" name="age" />
		<select name="interest[]" multiple>
			<option>Information Security</option>
		<input name="photo" type="file" />
	<button name="do" value="save">Save profile</button>
// Use type-safe getters to help write maintainable code.

// Handle multiple values with type safety.
foreach($input->getMultipleString("interest") as $interest) {

// Handle file uploads with a FileUpload object.
$photoUpload = $input->getFile("photo");
if($photoUpload instanceof FailedFileUpload) {
	// Handle a failed upload here.


Features at a glance

  • Type-safe getters, implementing the TypeSafeGetter interface.
  • Typed multiple getters, for working with checkboxes, multi-select elements or multiple file uploads.
  • "do" callback functions - hook up callbacks to button presses (implemented automatically in WebEngine applications).
  • "when" triggers - execute callbacks when certain user input is present.
  • FileUploadInputData class for easy file uploads, including functions such as moveTo(), getOriginalName(), etc.
  • Coming soon: working with huge files by streaming them to PHP, efficiently managing memory in the process.