app根目录下Request.php
<?php
namespace app;
// 应用请求对象类
class Request extends \think\Request
{
}
<?php
use app\ExceptionHandle;
use app\Request;
provider.php容器定义问题
// 容器Provider定义文件
return [
'think\Request' => Request::class,
'think\exception\Handle' => ExceptionHandle::class,
];
测试用应用Test:
Test.php(控制器)
declare (strict_types = 1);
namespace app\Test\controller;
use think\Request;
class Index
{
protected $request;
public function __construct(Request $request)
{
$this->request = $request;
}
public function index()
{
echo get_class($this->request);
dump ($this->request);
}
}
执行http://tp6.io/index.php/test/index/index/p/a
无法获取参数p。
问题在于app\Request这个类,我觉得没必要以think\Request绑定app\Reuqest,但问题不知出在哪里。
官方有空看下,或许是我的错。
最佳答案
