自动定位控制器
如果你使用了多级控制器的话,可以设置controller_auto_search参数开启自动定位控制器,便于URL访问,例如首先在配置文件中添加:
'controller_auto_search' => true,
然后定义控制器如下:
namespace appindexcontrollerone;
use thinkController;
class Blog extends Controller
{
public function index()
{
return $this->fetch();
}
public function add()
{
return $this->fetch();
}
public function edit($id)
{
return $this->fetch('edit:'.$id);
}
}
use thinkController;
class Blog extends Controller
{
public function index()
{
return $this->fetch();
}
public function add()
{
return $this->fetch();
}
public function edit($id)
{
return $this->fetch('edit:'.$id);
}
}
我们就可以直接访问下面的URL地址了:
http://serverName/index.php/index/one/Blog