Download the PHP package dive-be/laravel-dry-requests without Composer

On this page you can find all versions of the php package dive-be/laravel-dry-requests. 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-dry-requests

Warning two months after the release of our package, Taylor Otwell announced an almost identical functionality as a core package. Since this package has pretty much been made obsolete, we have decided to stop maintaining it.

So, please consider migrating to Laravel Precognition.

Social Card of Laravel Dry Requests

X-Dry-Run your requests

Latest Version on Packagist Total Downloads

This package allows you to check if your requests would pass validation if you executed them normally. The Laravel equivalent of --dry-run in various CLI tools, or what some devs call "preflight requests".

🚀 Hit the endpoint as users are entering information on the form to provide real-time feedback with 100% accuracy.

🚀 Validate only a subset of data of a multi-step form to guarantee success when the form is eventually submitted.

Showcase

What problem does this package solve?

A traditional approach to validating user input in JavaScript applications (Inertia / SPA / Mobile) is using a library such as yup to do the heavy lifting and delegating complex business validations to the server.

However, the client-side can never be trusted, so you can't simply omit the validation rules that ran on the front-end. This means that validation has to live in 2 distinct places and you will have to keep them in sync. This is very tedious and wasteful, so this is where this package comes into play.

Installation

You can install the package via composer:

You can publish the config file with:

This is the contents of the published config file:

Behavior

💡 Controller logic is not executed after a successful validation attempt. 200 OK is returned upon a successful dry run.

💡 Only present fields are validated to ensure good UX. Other fields are skipped using the sometimes rule. This means that you are responsible for only sending the relevant fields for validating e.g. a step of a multi-step wizard.

Usage

Assume the following endpoint: POST /users and Controller.

Option 1 - using FormRequests

Controller injecting a StoreUserRequest:

Add the DryRunnable trait to your FormRequest:

That's it 😎.

Option 2 - using validate method on the Request object

You don't have to do anything at all 🤙.

Front-end execution

Now, hit the endpoint from the client-side like you normally would. But with the added X-Dry-Run header.

Inertia.js example

Fine-tuning Dry Validations: AllFailures / FirstFailure

You can alter this behavior on 3 distinct levels.

  1. Change first to all (or vice versa) in the dry-request config file. This will apply to all of your requests.
  2. FormRequest only - Use the Dive\DryRequests\Dry attribute along with Dive\DryRequests\Validation on the rules method to force a specific Validation behavior for a particular FormRequest.

  3. Dictate the behavior on the fly from the front-end using the X-Dry-Run header. Valid values: all, first.

Note: the header value will be ignored if you have explicitly set a validation behavior on the FormRequest using the Dry attribute.

Conflicting FormRequest methods

The package makes use of the available methods passedValidation and withValidator available on FormRequest classes to enable its behavior.

If you define these in your own requests, you must call the "dry" methods manually:

Testing

Upgrading

Please see UPGRADING for details.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email oss@dive.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-dry-requests with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
dive-be/php-enum-utils Version ^1.1
dive-be/php-utils Version ^0.1.0
laravel/framework 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 dive-be/laravel-dry-requests contains the following files

Loading the files please wait ....