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

Trouble getting the tutorial working. (Apache)

I'm trying to get the tutorial working.

I'm getting an PhalconException: IndexController handler class cannot be loaded message

I have an alias set up as Alias /tutorial /opt/tutorial/public

When i accesst the page https://172.25.12.11/tutorial/ I get the error message.

mod rewrite is on. i have also tryed this in the main web dir with no change.

My file structure is

/opt/tutorial/
|-- .htaccess
|-- app
|   \-- controlers
|       \-- indexController.php -- (I have done upper and lower case i no change)
|   |-- models
|   \-- views
\-- public
    |-- .htaccess
    |-- css
    |-- img
    |-- index.php
    \-- js

indexController.php file

<?php

class IndexController extends \Phalcon\Mvc\Controller
{

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

}

index.php

<?php

try {
echo('1<br>');
    //Register an autoloader
    $loader = new \Phalcon\Loader();
    $loader->registerDirs(array(
        '../app/controllers/',
        '../app/models/'
    ))->register();
echo('2<br>');
    //Create a DI
    $di = new Phalcon\DI\FactoryDefault();
echo('3<br>');
    //Setup the view component
    $di->set('view', function(){
        $view = new \Phalcon\Mvc\View();
        $view->setViewsDir('../app/views/');
        return $view;
    });
echo('4<br>');
    //Setup a base URI so that all generated URIs include the "tutorial" folder
    $di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri('/tutorial/');
        return $url;
    });
echo('5<br>');
    //Handle the request
    $application = new \Phalcon\Mvc\Application($di);
echo('6<br>');
    echo $application->handle()->getContent();
echo('7<br>');
} catch(\Phalcon\Exception $e) {
     echo "PhalconException: ", $e->getMessage();
}

Page output

1
2
3
4
5
6
PhalconException: IndexController handler class cannot be loaded

/tutoral/.htaccess

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

/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>


1.6k

Don't forget to change AllowOverride None. to AllowOverride All in (httpd.conf) file



2.0k
edited Oct '14

I'm running ubuntu 12.04.05

When I put that in the httpd.conf (which is empty) I get the message

AllowOverride not allowed here Action 'configtest' failed.

So I put it in the apache2.conf before the line AccessFileName. I get the same error message.

The apache2.conf does include the httpd.conf file.

Any ideas where to put it?



98.9k

it must be IndexController.php instead of indexController.php



2.0k
edited Oct '14

I've used both IndexController.php and indexController.php with the same out come.

The files and directories are readable by the webserver user.



2.0k
Accepted
answer

Well I figured it out.

I had controlers instead of controllers. Missing one l.