控制器
根據(jù)PSR4規(guī)范,控制器類命名空間以plugin\{插件標(biāo)識(shí)}
開(kāi)頭,例如
新建控制器文件 plugin/foo/app/controller/FooController.php
。
<?php
namespace plugin\foo\app\controller;
use support\Request;
class FooController
{
public function index(Request $request)
{
return response('hello index');
}
public function hello(Request $request)
{
return response('hello webman');
}
}
當(dāng)訪問(wèn) http://127.0.0.1:8787/app/foo/foo
時(shí),頁(yè)面返回 hello index
當(dāng)訪問(wèn) http://127.0.0.1:8787/app/foo/foo/hello
時(shí),頁(yè)面返回 hello webman
url訪問(wèn)
應(yīng)用插件url地址路徑都以/app
開(kāi)頭,后面接插件標(biāo)識(shí),然后是具體的控制器及方法。
例如plugin\foo\app\controller\UserController
url地址是 http://127.0.0.1:8787/app/foo/user