$Hook = Container::get('hook',true);
$Hook->add('app_init','\\SunWork\\Base');
$Hook->listen('app_init',$Mc);大概这样一段代码接下来SunWork/ba
public function appInit($Mc){
$class = '\\app\\index\\controller\\Index';
$action = 'index'
if(method_exists($class,$action)){
echo 'index';
}
$class = "\\Origin\\" . $Mc->origin;
$origin = new $class();
if(method_exists($origin,"main")){
$request = $origin->main($SW);
}
}我自己定义的Origin被执行了但没有index被输出我页换了很多监听位,但都没有输出index
controller/Index.php
public function index(){
$class = '\\app\\index\\controller\\Index';
$action = 'index'
if(method_exists($class,$action)){
echo 'index';
}
}在这里是可以输出index的为什么在钩子里不能判断不出来?
如果我在钩子中实例化index 就会报错
但报错的内容会被另外一个错误替代

所以我也不知道错在那里
怀疑是没有注册app这个命名空间
1.如何在钩子中判断指定controller中判断是否有指定方法
2.图上这个错误如何解决
最佳答案