Download the PHP package yesccx/laravel-preparation without Composer

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

Laravel-Preparation

Laravel Http 前置处理器

For Laravel 5 Latest Stable Version Latest Unstable Version Total Downloads License

目录

安装

运行环境

运行环境要求
PHP ^8.1.0
Laravel Framework ^9.0

通过Composer引入依赖包

通过终端进入项目根目录,执行以下命令引入依赖包:

开始使用

简介

通常情况下,我们的接口实现是对一系列资源进行 增删改查 操作,例如 文章 就是资源,我们可能会编写 文章创建更新状态变更删除 等接口。这类接口的实现都有一共同逻辑,就是在做具体操作之前都需要检索出资源,如查询 文章表 判断 文章 是否存在。前置器的职责就是处理这一部分逻辑,它可以在控制器处理业务逻辑之前做一些初始化的判断或处理。

表单验证 的区别是,表单验证 通常只对数据进行 类型验证有效性验证 等,一般不涉及数据库查询操作,并且很难将验证过程中的一些中间数据暂存起来供后续业务逻辑处理时使用,而前置器很好的解决了这一问题。

编写前置器

创建一个前置器类并继承 Yesccx\Preparation\BasePre 基类,同时在 handle 方法中实现需要前置处理的逻辑,其中 handle 方法支持依赖注入,最终我们可以将处理过程中产生的中间数据或结果数据暂存到成员变量中,供后续业务使用。前置器还可以通过基类中的 fail 方法中止前置验证,fail 方法默认会抛出一个 PreparationException 异常。

下述代码中,将定义好的前置器声明到控制器方法上,Laravel 在执行 update 方法之前会先进行前置器处理,然后再经过验证器验证,同时我们可以在方法中直接拿到 UserPre 前置器中处理过的数据。

使用建议

License

MIT


All versions of laravel-preparation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1.0
laravel/framework Version ^9.0.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 yesccx/laravel-preparation contains the following files

Loading the files please wait ....