Phalcon tutorial error PhalconException: TestController handler class cannot be loaded

前提是你 提交于 2019-12-05 16:58:36
Marcone

Replace in bootstrap file index.php

$url->setBaseUri('/tutorial/');

with

$url->setBaseUri('/');

My bad, this isn't an error. The Phalcon tutorial seems to expect that the tutorial is being completed in a directory called /test/, not web root. It doesn't specify this, so I assumed /test would produce the behaviour shown in the tutorial with the project in web root.

You need change Dir of Controllers and Models if u run localhost/test.php

try {
//Register an autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
    'app/controllers/',
    'app/models/'
))->register();

//Create a DI
$di = new Phalcon\DI\FactoryDefault();

//Setup the view component
$di->set('view', function(){
    $view = new \Phalcon\Mvc\View();
    $view->setViewsDir('app/views/');
    return $view;
});

//Setup a base URI so that all generated URIs include the "tutorial" folder
$di->set('url', function(){
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri('/');
    return $url;
});

//Handle the request
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!