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

[AWS-EC2] PhalconException: IndexController handler class cannot be loaded

Hello everyone,

I'm trying to make Phalcon work on a instance in my EC2 panel, everything went fine and the framework apparently installed successfully, but for some reason when I try to load an application (Tutorial 1 from phalcon's site) it just don't work and throw me this error:

PhalconException: IndexController handler class cannot be loaded

I've tried many kinds of solution, but them showed unsuccessful, and I really didn't know what to do to make it run properly.

  • Ps1.: The same application is running normally in my local environment
  • Ps2.: Yes, i've created the tutorial's database/table on my EC2 instance and do have mysql installed
  • Ps3.: Phalcon seems to be installled properly, when i run some php command to show extensions phalcon is there, when i run echo \Phalcon\Version::get(); it throws me: 0.9.1 so i assume it is properly installed.

My instance is running Ubuntu 12.10 Server 32bit, if it helps. (And locally, I'm using OSX)

Did someone faced this issue before? Can it be some problem with Phalcon's installation or maybe another quirk? Maybe some .htaccess problem (it was blocked by default, I had to do some changes into httpd.conf)?

I would really appreciate some help here. :)



98.9k

Thanks for opening this here, the apacheconf I posted on Github didn't work?

Nope.

I added that code into /etc/apache2/httpd.conf file, but it didin't work.

Also, .htaccess files seems to be working as well, if i do some change (eg.: delete some character from rules) in some .htaccess file it throws me an error, so its probably running well.

Very strange. The main problem is that i don't know from where the issue is, if it is .htaccess problem, or apache/php configs, or phalcon extension, etc.

Phalcon 0.9.1 works with php 5.4.12-2 (the version used in my EC2 instance) too, right?



98.9k

Maybe there is a problem with case-sensitiveness, Mac OS X is not case sensitive while Linux is.

This website is running with Phalcon on EC2.



98.9k

Also, this is the virtual host config for this website:

<VirtualHost *:80>

        ServerName forum.phalcon.io

        DocumentRoot /srv/www/forum/public

        <Directory "/srv/www/forum/public">
                AllowOverride All
                Options All
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

And the code: https://github.com/phalcon/forum

Double check your path for controllers dir in config (or in code).

When i try to include the paths manually in index.php (just to check if the path routes are working) it seems to work well. But for some reason it keeps sending me this message error when its in config file.

If i put:

$test = include("../app/controllers/indexController.php");

if($test){
    echo "success";
}else{
    echo "fail";
}

into index.php it shows me: "success"

But when i use the same path to determine controller/models way,

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

it gives me

PhalconException: IndexController handler class cannot be loaded


18.5k
Accepted
answer

"indexController.php" - must be CamelCase!

yep, that was it!

controller names must be CamelCase (ExampleController) and my file was renamed like (exampleController). Simple like that.

I hope this journey serve as example for the new incoming adepts of the framework. ALWAYS CHECK YOUR FILES NAMES. :)

Thanks @lantian for helping me solve this newbie problem, Thanks @Phalcon to readily try to help me here and in github.

But............

for some reason it doesn't load the views, when i try to instead of the error, now it shows a blank page, with nothing in it. If i put a echo directly into IndexController it shows up for me, but the view itself don't appears.

=). It seems that view not found. Double check it =))). It must be in /views/index/index.volt[php] where /[viewsDir]/[ControllerName]/[ActionName].EXT ... all names in path must be in lowercase



3.8k
edited Oct '14

was getting the same, running the built in php server

solution was full path names my bootstrap is in /app/bootstrap.php in index.php in require_once('../app/bootstrap.php');

<?php

try
{

    //Register an autoloader
    $loader = new \Phalcon\Loader();
    $loader->registerDirs(array(
        __DIR__ . '/' . 'controller/',
        __DIR__ . '/' . 'model/'
    ))->register();

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

    //Setting up the view component
    $di->set('view', function(){
        $view = new \Phalcon\Mvc\View();
        $view->setViewsDir(__DIR__ . '/' . 'view/');
        return $view;
    });

    //Handle the request
    $application = new \Phalcon\Mvc\Application();
    $application->setDI($di);
    echo $application->handle()->getContent();

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


71

Hello, when I click in sign Up Here! I have the follow, Exception: TutorialController handler class cannot be loaded, I get the code exemple at https://github.com/phalcon/tutorial someone can help me ?

edited Mar '15

Hello, when I click in sign Up Here! I have the follow, Exception: TutorialController handler class cannot be loaded, I get the code exemple at https://github.com/phalcon/tutorial someone can help me ?

Yeah, in your bootloader (index.php) change the base directory to '/' instead of '/tutorial/'.



85
edited Sep '17

i am getting the same issue: PhalconException: PageController handler class cannot be loaded

My issue is not because of CamelCase and my base uri code is this:

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

This issue is coming for only few pages remain all are working fine. what colud be the possible error.?

edited Aug '20

try this

echo $application->handle($_GET['_url'] ?? '/')->getContent();