Skip to content

Commit

Permalink
调整应用中间件的执行顺序
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Mar 1, 2020
1 parent b81f75f commit ec04f50
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions src/Service.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think\app;

use think\Service as BaseService;

class Service extends BaseService
{
public function register()
{
$this->app->middleware->unshift(MultiApp::class);

$this->commands([
'build' => command\Build::class,
'clear' => command\Clear::class,
]);

$this->app->bind([
'think\route\Url' => Url::class,
]);
}
}
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think\app;

use think\facade\Event;
use think\Service as BaseService;

class Service extends BaseService
{
public function register()
{
Event::listen('HttpRun', function () {
$this->app->middleware->add(MultiApp::class);
});

$this->commands([
'build' => command\Build::class,
'clear' => command\Clear::class,
]);

$this->app->bind([
'think\route\Url' => Url::class,
]);
}
}

0 comments on commit ec04f50

Please # to comment.