Download the PHP package limingxinleo/x-phalcon-middleware without Composer
On this page you can find all versions of the php package limingxinleo/x-phalcon-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download limingxinleo/x-phalcon-middleware
More information about limingxinleo/x-phalcon-middleware
Files in limingxinleo/x-phalcon-middleware
Download limingxinleo/x-phalcon-middleware
More information about limingxinleo/x-phalcon-middleware
Files in limingxinleo/x-phalcon-middleware
Vendor limingxinleo
Package x-phalcon-middleware
Short Description a phalcon middleware component
License MIT
Package x-phalcon-middleware
Short Description a phalcon middleware component
License MIT
Keywords phalconphalcon-middleware
Please rate this library. Is it a good library?
Informations about the package x-phalcon-middleware
x-phalcon-middleware
a phalcon middleware component
感谢
https://github.com/shouhuyou/phalcon-midddleware.git
安装
composer require limingxinleo/x-phalcon-middleware
配置
添加服务
- 控制器中使用中间件
中间件执行顺序
中间件定义
class OneMiddleware extends Middleware
{
public function handle($request, Closure $next)
{
echo 'One1' . PHP_EOL;
$response = $next($request);
echo 'One2' . PHP_EOL;
return $response;
}
}
class TwoMiddleware extends Middleware
{
public function handle($request, Closure $next)
{
echo 'Two1' . PHP_EOL;
$response = $next($request);
echo 'Two2' . PHP_EOL;
return $response;
}
}
class ThreeMiddleware extends Middleware
{
public function handle($request, Closure $next)
{
echo 'Three1' . PHP_EOL;
$response = $next($request);
echo 'Three2' . PHP_EOL;
return $response;
}
}
class FourMiddleware extends Middleware
{
public function handle($request, Closure $next)
{
echo 'Four1' . PHP_EOL;
$response = $next($request);
echo 'Four2' . PHP_EOL;
return $response;
}
}
使用如下
/**
* Class IndexController
* @package Tests\App\Controllers
* @Middleware('sort1')
*/
class IndexController extends Controller
{
public function initialize()
{
$this->middleware->set([
'abs',
'test3'
]);
}
/**
* @Middleware('sort2')
* @Middleware('sort3')
*/
public function indexAction()
{
return $this->response->setJsonContent([
'success' => true,
'data' => ['action' => 'index']
]);
}
}
结果
'abs.start',
'test3.start',
'sort1.start',
'sort2.start',
'sort3.start',
'sort3.end',
'sort2.end',
'sort1.end',
'test3.end',
'abs.end',
All versions of x-phalcon-middleware with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.5
ext-phalcon Version ^3.0
ext-phalcon Version ^3.0
The package limingxinleo/x-phalcon-middleware contains the following files
Loading the files please wait ....