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

IndexController handler class cannot be loaded - Tutorial

Hi all,

Excited to get Phalcon running, but seeing some challenges.

Environment: OSX Mav, Apache 2.2, php 5.4

Dir Structure:

/phalcon_test/
    app
    public

Code (index.php)

use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;

try {

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

    // Create DI
    $di = new FactoryDefault();

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

    // Setup base URI/all base URLs include the sub dir phalcon_test
    $di->set('url', function(){
        $url = new UrlProvider();
        $url->setBaseUri('/phalcon_test/');
        return $url;
    });

    // Handle the request
    $application = new Application($di);

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

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


34.6k
Accepted
answer

Check this repository on Github, it has the tutorial code you need to make the example work: https://github.com/phalcon/tutorial

Wow, that told me something I missed. IndexController.php for the file name, not index,php ;) Andres, thank you!!!!