Phalcon manual error PhalconException: TestController handler class could not be loaded

I am having trouble working with PhalconTutorial 1. In the end, I cloned its version on Githubto make sure I didn't miss anything; still getting the same behavior from this.

Pointing the browser to localhost / test, as shown in the tutorial, gives: `

"PhalconException: TestController handler class cannot be loaded".

Switching to localhost/test.php, however, loads "Hello!" test message.

Falcon is shown in phpinfo() and get_loaded_extensions().

I get this behavior even by cloning a tutorial from

https://github.com/phalcon/tutorial .

I assume that it apachedoesn’t rewrite URLs correctly, as described in Phalconphp routes do not work , but my problem is not like the one there.

Htaccess file contents:

#/tutorial/.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule  ^$ public/    [L]
    RewriteRule  (.*) public/$1 [L]
</IfModule>

and

#/tutorial/public/.htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
+4
source share
3 answers

Replace in bootstrap file index.php

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

from

$url->setBaseUri('/');
+7
source

My bad, this is not a mistake. The Phalcon tutorial seems to expect the tutorial to be completed in a directory called / test /, and not in a web root. He does not indicate this, so I assumed that / test will lead to the behavior shown in the tutorial, with the project in the web root.

+2
source

Dir , 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();
+2

All Articles