Download the PHP package fadion/rule without Composer

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

Rule

A simple Laravel package that provides an expressive alternative to building validation rules. It uses what you already know about validation with Laravel and builds on top of that.

Instead of this:

You'll be writing:

Which method is more easy to read or write is a matter of personal preference, so I'm not taking sides. However, using Rule offers two main advantages:

  1. Misstyped rule names, non existing rules or missing arguments will throw fatal errors. In contrast, Laravel's rules will fail silently and provide no information when you write 'reqiured' instead of 'required'.
  2. IDE suggestions and auto complete. Every rule is a real, documented method that your IDE can easily pick up. Coupled with Laravel IDE Helper, you'll rarely need to open the Validator docs.

Installation

  1. Add the package to your composer.json file and run composer update:

  2. Add Fadion\Rule\RuleServiceProvider::class to your config/app.php file, inside the providers array.

  3. Add a new alias: 'Rule' => Fadion\Rule\Facades\Rule::class to your config/app.php file, inside the aliases array.

For Laravel 4, use version 1.0

Usage

If you've used Laravel's Validator, then you already know how to use Rule. It just changes the way you write rules, but the validation process remains exactly the same.

A complete validation example

Rules with parameters

Rule parameters are handled as simple method arguments. There can be one or more arguments, depending on the rule and some can be arrays too (like: in, not_in, mimes, etc.).

Exists and Unique

exists and unique are special cases, as they have a few defined and documented arguments, as well as dynamic ones for the where clauses.

Custom rules

Rule handles custom rules in the same way as the predefined ones. It even accepts parameters.

Array rule

Laravel's rule for validating an input as array is renamed to is_array(). The word "array" is reserved in PHP and can't be used as a method name, hence the rename.

Method names

Methods can be written as either snake_case (as Laravel accepts rule names) or as camelCase. Both cases behave exactly the same, so use whatever feels better.

So, the methods below are equivalent:

Attribute names

Laravel has an option to alias input names with custom attributes, as a way to build better error messages. Rule provides an easy way to create them.

Messages

There's no way that you start writing expressive rules, but keep messages as arrays. Rule will handle those too in a very elegant and easy to use way. Just add a message() method after the rule:


All versions of rule with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~5.1
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 fadion/rule contains the following files

Loading the files please wait ....