请教个问题:
yaf. use_namespace=1的情况下,controller怎么使用namespace?
比如:Index.php的内容
use Yaf\Controller_Abstract;
use Yaf\Dispatcher;
class IndexController extends Controller_Abstract
{
public function indexAction()
{
Dispatcher::getInstance()->disableView(0);
echo 'Great,It Works!';
}
}
没法加namespace了,文件名是Index.php
路过的怎么处理的,说说
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我也想知道答案。 原本想
一直报错。去掉
namespace App\Controllers
就行。不知道怎么办了。php.ini 开启
定义加载器 可以在公用function中
然后在 Bootstrap 文件中用 spl_autoload_register 自定义加载器
不过开启 use_spl_autoload 会影响效率
use_spl_autoload
也是一直报错,原来是index里加了
namesapce App\Controllers
yaf中的controller,model都是属于根命名空间,无需再去定义,自动引入机制这是写在扩展中的,没必要处理
个人总觉得在一个文件里写一堆的use ......;不太美观。如果跨项目调用 这个文件,会不会出错呢。