报一个Thinkphp6.0示例应用的代码问题【望官方一阅】

浏览:5285 发布日期:2019/11/06 分类:ThinkPHP6专区
再次做了实验,provider.php文件放在/app下的话,程序运行正常。如果方式/app/index(某个应用下)将导致Request无法获取param等错误。

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,但问题不知出在哪里。
官方有空看下,或许是我的错。
最佳答案
评论( 相关
后面还有条评论,点击查看>>