Download the PHP package uniondrug/middleware without Composer

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

Uniondrug Middleware 中间件组件

基于Phalcon的uniondrug/framework项目中,增加中间件处理流程的支持。

感谢

https://github.com/limingxinleo/x-phalcon-middleware https://github.com/fastdlabs/middleware

安装

使用

修改配置文件,引入中间件组件

app.php配置文件中增加中间件组件的注册

添加middlewares.php配置文件,定义中间件

开发中间件

创建中间件。中间件必须从Uniondrug\Middleware\Middleware继承。实现handle方法。该方法有两个参数:request是Phalcon的Phalcon\Http\Request对象,next是下一个中间件代理。 在处理过程中,可以直接返回一个Phalcon\Http\Response对象,终止后续的中间件,或者返回下一个中间件代理的处理结果(链式传递)。

中间件开发好后,需要在middleware.php配置文件中注册一个别名,在使用过程中以别名调用。

使用中间件

中间件在控制器中使用。在控制器中有两种方法定义需要使用哪些中间件。

1、在beforeExecuteRoute()方法中配置。

通过middlewareManager组件的bind方法,指派对应的中间件。

其中第一个参数是控制器本身,

第二个参数是一组中间件别名,

可选的第三个参数可以指明中间件的绑定范围: only 指只有在列表中的 action 使用该组中间件 except 指除了列表中的 action 以外的所有方法使用该组中间件 如果only/except都不指定,那么整个控制器的方法都会使用改组中间件

2.通过注解的方法定义中间件

注解Middleware定义当前控制器或者方法使用的中间别名。可以定义多个。

中间件调用的顺序

bind()方法定义超过一个中间件时,从后到先倒序执行。

比如上面例子里面的indexAction被调用时,中间件的执行顺序是:

前置调用

后置调用

前置调用 & 后置调用

NOTE:Phalcon的Request对象不同于Psr的HttpRequest对象,它只是PHP原生超全局变量$_GET/$_POST/$_SERVER/$_REQUEST的封装,所以如果想在Middleware中对请求对象进行 改写并且让他影响后续使用,那么直接操作超全局变量。

内置中间件

组件自带了几个实用的中间件,在middleware.php配置文件中增加配置即可使用。


All versions of middleware with dependencies

PHP Build Version
Package Version
Requires uniondrug/framework Version ^2.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 uniondrug/middleware contains the following files

Loading the files please wait ....