Reputation: 1747
I have been trying to create a custom controller that extends UserFrosting's BaseController and then call it's method from index.php. Seems simple, but so far I am highly unsuccessful. I am new to UserFrosting, hence I am most likely missing something obvious.
controllers/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
]);
}
}
index.php:
...
use UserFrosting as UF;
$app->get('/lg/requests/?', function () use ($app) {
$controller = new UF\LGController($app);
return $controller->lgRequestsList();
});
...
Error:
[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
Upvotes: -1
Views: 225
Reputation: 8688
Don't use include
to include your new controller class. UserFrosting uses Composer to autoload your files.
Once you install Composer globally, all you need to do is run composer dump-autoload
in your userfrosting/
subdirectory, and it will add the new class for you.
Upvotes: 3