Download the PHP package konsulting/laravel-rule-repository without Composer

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

Laravel Rule Repository

Build Status Code Coverage Scrutinizer Code Quality

A package to allow rules (for example validation rules) to be attached to a model, whilst avoiding storing them on the model itself or in a controller.

Installation

Install via Composer:

Usage

Each model under validation should have its own validation repository attached to it, containing default validation rules and, optionally, validation rules for different states. You may, for example, require different validation rules when updating the model as opposed to creating it.

Creating the repository

The validation repository must implement Contracts\RuleRepository, and as such must contain a default() method which returns an array of default rules. It may also contain any number of 'state' methods which contain differing rules.

Note:

Extending the AbstractRepository class

The AbstractRepository class is provided with some helper functions to make defining rules easier. This class may be extended instead of directly implementing the interface.

Sometimes it's useful to append or prepend a rule to an existing list of rules, e.g. making values required only on model creation. This is possible with the following methods:

Example repository:

Attaching the repository to the model

The model to attach the rules to should use the RuleRepositoryTrait trait. It is recommended (but not required) that the model implements the interface Contracts\HasRuleRepositories.

The static property $ruleRepositories should be initialised to an associative array of repository class paths, with the repository name as the key.

Retrieving validation rules

The model's validation rules can be retrieved using the static method getRules($name, $state = 'default').

To return the default rules for the validation repository:

To get state-specific rules:

States may be named in either camel-case or snake-case.

Using magic methods

The RepositoryMagicMethods trait may also be added to the model to allow rules to be retrieved with a more concise syntax. Rules may be retrieved using:

For example:


All versions of laravel-rule-repository with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0||^8.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 konsulting/laravel-rule-repository contains the following files

Loading the files please wait ....