Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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();
}


33.5k
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!!!!