Mr world wide
Mr world wide

Reputation: 4814

PhalconException: NameController handler class cannot be loaded

Tried with the question but it didn't fix my issue. : Phalcon tutorial error PhalconException: TestController handler class cannot be loaded

My application is in AWS ubuntu 14.0 and some pages are working fine but for few pages, I'm getting this error:

PhalconException: NameController handler class cannot be loaded.

My controller names are CamelCase!

//Setup a base URI so that all generated URIs include the "tutorial" folder
$di->set('url', function(){
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri('/');
    return $url;
});

I changed my apache2.conf file to AllowOverride : all:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
</Directory>

My App is here projectname/admin/app/:

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

cant able to debug this can anyone help what else could be the issue.?

Upvotes: 1

Views: 9997

Answers (3)

M.Haris
M.Haris

Reputation: 769

I was getting this error so i fixed it in public/index.php

  • Find the line echo $application->handle($_SERVER['REQUEST_URI'])->getContent() or echo $application->handle()->getContent() or code related to this.
  • The main error is request_uri which is redirected to wrong controller
  • for example if you try to echo $_SERVER['REQUEST_URI'], it will also show the domain name.
  • so i fixed it locally like this. Replace this whole line with following code
 $request_uri=str_replace(["\n","\r","\t"], '', $_SERVER['HTTP_HOST']);
            if($request_uri=='localhost'){
                $url=explode('/',$_SERVER['REQUEST_URI']);
                array_shift($url);
                array_shift($url);
                $url=implode('/',$url);
                $url='/'.$url;
            }
            else
                $url=$request_uri;
        echo $application->handle($url)->getContent();

OR Simply use /{controller name}/{function name} in handle function

  • The main error was that it was redirecting to domain named controller because of $_SERVER['REQUEST_URI'] but we have to ignore domain name and redirect it to controller name.

Upvotes: 1

Juri
Juri

Reputation: 1369

This simply means that such controller doesn't exists, like class isn't loaded.

Upvotes: 0

asif
asif

Reputation: 279

If the controller page is not present in controllers then this issue will come, so plz recheck the controller page exists or not.

Upvotes: 1

Related Questions