We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

class cannot be loaded

Hello all. I write simple example from documentation - https://docs.phalcon.io/en/latest/reference/tutorial.html#creating-a-project, but when i start looking in browser, phalcon get error - Exception: IndexController handler class cannot be loaded.

<?php
 try {
    $loader = new \Phalcon\Loader();
    $loader->registerDirs(array(
        '../app/controllers/',
        '../app/models/'
    ));

    $di = new Phalcon\DI\FactoryDefault();

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

    $di->set('url', function(){
        $url = new Phalcon\Mvc\Url();
        $url->setBaseUri('/phalcon/');
        return $url;
    });

    $application = new Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

} catch (\Phalcon\Exception $e) {
    echo 'Exception: ', $e->getMessage();
}

```php<?php class IndexController extends \Phalcon\Mvc\Controller {

public function indexAction()
{
    echo '<h1>Hello</h1>';
}

}


What I'm doing wrong? Thanks.

P.S. Using xampp 1.8.2.

Can you see if you can get one of the sample apps up and running such as INVO or vokuro? They are more fleshed out examples with routes, namespaces, etc.



4.2k

Thanks. I wiil be use Vokuro, but i want to know, what I'm doing wrong? When I understand error, in future I will not take that twice =)

Honestly, I'm not sure. I've never tried just the very simple setup from the docs. The sample apps all have a bit more in their DI setup with things like a router, dispatcher, namespaces, etc. It could be that the docs tutorial is missing something, or your setup is. I suggested teh sample apps, because if those don't load, you know something is missing in your setup.



4.2k

You're very help to me, Mark! Thanks =) Topic can be close.