我一直在尝试创建一个扩展UserFrosting的BaseController的自定义控制器,然后从index.php调用它的方法。看起来很简单,但到目前为止我非常不成功。我是 UserFrosting 的新手,因此我很可能遗漏了一些明显的东西。
控制器/LGController.php:
<?php
namespace UserFrosting;
class LGController extends \UserFrosting\BaseController {
public function __construct($app){
$this->_app = $app;
}
public function lgRequestsList(){
$groups = array('Luke #1', 'Luke #2');
$this->_app->render('lg-request-list.twig', [
"groups" => $groups
]);
}
}
索引.php:
...
use UserFrosting as UF;
$app->get('/lg/requests/?', function () use ($app) {
$controller = new UF\LGController($app);
return $controller->lgRequestsList();
});
...
错误:
[Wed Nov 09 15:25:40 2016] [warn] [client 160.34.126.11] mod_fcgid: stderr: Fatal error (1) in /home2/test/public_html/index.php on line 66: Class 'UserFrosting\\LGController' not found, referer: http://xxx.co.uk/groups/g/1/auth