Download the PHP package buffary/phalcon-middleware without Composer
On this page you can find all versions of the php package buffary/phalcon-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download buffary/phalcon-middleware
More information about buffary/phalcon-middleware
Files in buffary/phalcon-middleware
Download buffary/phalcon-middleware
More information about buffary/phalcon-middleware
Files in buffary/phalcon-middleware
Vendor buffary
Package phalcon-middleware
Short Description a phalcon middleware component
License MIT
Package 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 phalcon-middleware
x-phalcon-middleware
a phalcon middleware component
感谢
https://github.com/shouhuyou/phalcon-midddleware.git
安装
composer require buffary/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 phalcon-middleware with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.4
ext-phalcon Version ^4.0
ext-phalcon Version ^4.0
The package buffary/phalcon-middleware contains the following files
Loading the files please wait ....