Download the PHP package lusito/insanity without Composer

On this page you can find all versions of the php package lusito/insanity. 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 insanity

InSanity

License

Master Build Status Code Coverage
Develop Build Status Code Coverage

Extensible validation and sanitization library for various input sources like $_POST and routing parameters.

Why InSanity?

Note: This has just been released, so it might not be perfect yet. Feel free to report issues, improvement ideas or create pull requests.

Requirements

Installation

Install via composer:

Include the autoloader in your php script, unless you've done that already:

Usage

An example use-case:

Alternatively, you can grab the values manually like this:

The classes

This library consists of these classes:

The last 3 classes can be extended or even replaced with your own implementations if you feel like it.

Details follow:

InSanity

This class receives 3 parameters:

To start validation and sanitization on a field, call it like this:

This consists of 2 parts:

You can get errors using $in->getErrors(). If you need to access a field afterwards (or apply an additional later), you can access the fields later by using $in->my_field_name.

For convenience, a method $in->toJSON() exists, which will create an associative array field_name => field_value.

Field

Field instances are created by InSanity (see above). The instance supports executing and chaining rules.

A rule can be run in 3 different ways:

The rule (and filter) methods are applied in order. If the given method returns a boolean value, it's interpreted as a rule, otherwise as a filter (the sole exception is boolval, see below).

Examples:

Some methods exist in addition to normal rule handling:

RuleHandler

As said, RuleHandler contains validation methods. That method receives 1-2 parameters. The first being the value to validate and the second is the parameter passed by the user (null if none given).

The following rules are included in the built-in RuleHandler class:

Translator

If you plan on writing your own rules or if you need more than english as target language, you can either add/override translations by supplying an associative array to the constructor or you can write your own implementation.

ErrorHandler

The ErrorHandler builds and aggregates error messages. It will create a new Translator instance when needed. If you want it to use a custom Translator instance, either pass the instance as first argument to the constructor, or override the getTranslator() method.

Report isssues

Something not working quite as expected? Do you need a feature that has not been implemented yet? Check the issue tracker and add a new one if your problem is not already listed. Please try to provide a detailed description of your problem, including the steps to reproduce it.

Contribute

Awesome! If you would like to contribute with a new feature or submit a bugfix, fork this repo and send a pull request. Please, make sure all the unit tests are passing before submitting and add new ones in case you introduced new features.

License

InSanity has been released under the zlib/libpng license, meaning you can use it free of charge, without strings attached in commercial and non-commercial projects. Credits are appreciated but not mandatory.


All versions of insanity with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.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 lusito/insanity contains the following files

Loading the files please wait ....