Download the PHP package square/laravel-hyrule without Composer

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

Laravel Hyrule

Hyrule provides an object-oriented, fluent API for building validation rules for use w/ Laravel's Validation component. This unlocks patterns that make it easier to define set of rules to enforce complex, nested data structures that is typical in API development.

Why:

Defining validation rules in Laravel involves manually building arrays. As business logic evolves and validation rules become more complex, those arrays grow in size, and building them also becomes more complex. Before long, you find yourself manipulating arrays: adding or removing rules based on conditions, refactor segments to be re-used, etc. and over time, this pattern can feel really clunky. It doesn't take a lot to make managing validation rule definitions feel like it's getting out of control. This library aims to fix that by offers a better API that helps you for the long-term:

Installation

For PHP 7.4 support, install the 1.* versions. See 1.x README

Setup

1.) If you do not have package discovery enabled, you will have to manually register the service provider:

2.) Publish the config:

Using the service provider & the default config will allow your app to use StrictValidator.

API Basics

Initializing a rule-builder and adding your first field:

Fleshing out the rest of your fields & their rules:

Start validating!

Fields API

Hyrule forces you to define the expected data-type for each field. It supports all ranges of types, from scalar types to non-scalar types.

Scalar Types

Adding scalar fields are as easy as:

Non-Scalar Types

No matter how deep and complex your validation rules go, you can use the same set of APIs:

Objects

Use ->object(...) to start defining nested fields e.g.

Unknown fields

By default, Hyrule helps you build robust & secure applications by only allowing fields you explicitly defined via the Fields API. This is specifically designed to help you be intentional w/ what you expect from your data. For example, this is another mechanism by which your API can further sanitize user input.

If you expect a field to come through, the library would still require you to specify the data-type. But you don't have to specify other rules:

If you'd like to allow unknown fields through, use this method on the appropriate node(s):

Arrays of scalar values

You guessed it: Start with ->array():

As you can see in this example, Hyrule promotes strictness even for what goes in arays.

Arrays of objects

Just define it like any other array field, and use the exact same API to define the nested fields:

File Uploads

As of 2.3, Hyrule supports specifying rules for file uploads:

See the following detailed guides on how to validate file uploads by file-type (MIME type), dimensions, etc.

Rules API

First let's talk about what happens when you use the Fields API described above. When you define a field, a node is created & returned by the builder. You can then use the Rules API to add validation rules on a node.

Basic Example
Custom Rules Support

This library helps you build validation rule definitions & does not limit you from using custom rules that doesn't come w/ Laravel:

What's up with ->end()?

Once you understand that Square\Hyrule\Builder manages a tree of nodes and that the Fields APIs return child nodes, all you have to know is that ->end() returns the parent of the node, and it is the fluent way of traversing back up the tree:

If you are not a fan of this, you can use the Fields-With API.

Advanced Topics


All versions of laravel-hyrule with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/validation Version ^10.0
illuminate/support Version ^10.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 square/laravel-hyrule contains the following files

Loading the files please wait ....