Download the PHP package netherphp/input without Composer

On this page you can find all versions of the php package netherphp/input. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package input

Nether Input

nether.io Code Climate Build Status Packagist Packagist

An input filtering interface. It allows you to define a set of dynamic filters for input to be run applied just-in-time on your specified data source.

Super simple example:

$input = (new Nether\Input\Filter)
->Email(function($t){ return filter_var($t,FILTER_VALIDATE_EMAIL); });

// ... some time later...

$input->SetDataset($_POST);
if(!$input->Email) {
    throw new Exception('valid email address is required.');
}

To pull this off, things like your HTML form field names will need to follow the same rules as properties in PHP (alphanumeric and _ starting with a letter). By default it is case insensitive, so you can send all lowercase from your URL if you want and then reference them in whateverCase YouChoose to use. That can be disabled if you are on a performance powertrip.

You can pass any array or object to the constructor or use SetDataset(). Typical uses would be for _GET and _POST but you could apply it to any named dataset that needs looked at. You can also change datasets at will, keeping any predefined filters intact.

Another Simple Example:

Lets say we want to dump our POST data back into our form because there was some sort of validation error. This is the time where it is very easy to accidentally open yourself up to cross-site scripting problems. Input Filter can take care of that for you though by defining a default filter that all fields which do not have their own special filters for, get run through.

$data = (new Nether\Input\Filter($_POST))
->SetDefaultFunction(function($v){ return htmlspecialchars($v) });

// ... some time later...

<input type="text" name="Username" value="" />

Creating a new interface.

Wrap any object or array in the OOP interface.

$input = new Nether\Input\Filter($_POST);

Retrieve a value.

Fetch the value from $_POST['myfield'], after running it through any filters we assigned to the field.

$val = $input->MyField

Set a value.

Note, this will not update the original source array. Writing back to the dataset will prompt the copy-on-write, so now you have your own unique dataset and in this example, will not affect the original $_POST['myfield'].

$input->MyField = 'ten';

Set a filter.

You call the field as a method, passing it a callable function with one argument which is the value.

$input->MyField(function($t){
    return str_repalce('a','@',$t);
});

Retrieve a filter.

You invoke the object directly, passing it a string that was the name of the field you originally defined the callback on. Here is an example reusing an existing callback on another field.

$input->MyOtherField($input('MyField'));

Installing

Require this package in your composer.json.

require {
    "netherphp/input": "~1.0.0"
}

Then install it or update into it.

$ composer install --no-dev
$ composer update --no-dev

Testing

This library uses Codeception for testing. Composer will handle it for you. Install or Update into it.

$ composer install --dev
$ composer update --dev

Then run the tests.

$ php vendor/bin/codecept run unit
$ vendor\bin\codecept run unit

All versions of input with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
netherphp/object Version >=3.0.0
netherphp/option Version >=1.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package netherphp/input contains the following files

Loading the files please wait ....