framework icon indicating copy to clipboard operation
framework copied to clipboard

tp6 服务类的Request与控制器的Request实例不是一个

Open wdaglb opened this issue 5 years ago • 0 comments

provider.php

<?php
use app\library\ExceptionHandle;
use app\library\Request;

// 容器Provider定义文件
return [
    'think\Request'          => Request::class,
    'think\exception\Handle' => ExceptionHandle::class,
];

AppService

class AppService extends Service
{
    public function boot(Request $request)
    {
        var_dump($request);
    }
}

IndexController

class IndexController extends BaseController
{
    public function index()
    {
        var_dump($this->request);
    }

}

最后服务打印的是object(app\library\Request)#25

控制器是object(app\library\Request)#59

wdaglb avatar Feb 22 '21 06:02 wdaglb