Cphalcon: NameController handler class cannot be loaded

Created on 14 Mar 2020  路  5Comments  路  Source: phalcon/cphalcon

I have create a new application over a new server.
Everything seems ok and I have create a new project in _public_html_ folder, like:

phalcon project name --enable-webtools

Really seems everything is ok and the squeleton appears fine

To Reproduce
When I test http://www.mydomain.ext/name the response is:

NameController handler class cannot be loaded

#0 [internal function]: Phalcon\Mvc\Dispatcher->throwDispatchException()
#1 [internal function]: Phalcon\Dispatcher\AbstractDispatcher->dispatch()
#2 /home/tecmp/web/tecmp.com/public_html/name/public/index.php(55): Phalcon\Mvc\Application->handle()
#3 {main}

So, the line 55 of index.php is:

echo $application->handle($_SERVER['REQUEST_URI'])->getContent();

I have tested several ways in config.php

'baseUri'        => '/',
or
'baseUri'        => '/name/',  
etc...

Expected behavior
The initial and automatic page/point of Phalcon. (controllers/IndexController.php)

Details

  • Phalcon version: 4.0.5
  • PHP Version: = 7.4
  • Operating System: CentOS 7x
  • Installation type: Compiling from source || installing via package manager
  • Zephir version: Powered by Zephir => Version 0.12.17
  • Server: Nginx & Apache

Additional context
The same new project in Phalcon 3.x works perfectly.
Thanks for your help in advance.

bug unverified

Most helpful comment

Hi @tallande,
Did you try to update the line 55 of index.php:
echo $application->handle($_SERVER['REQUEST_URI'])->getContent();
to
echo $application->handle($_GET['_url'] ?? '/')->getContent();

I hope it will solve your problem.

All 5 comments

Hi @tallande,
Did you try to update the line 55 of index.php:
echo $application->handle($_SERVER['REQUEST_URI'])->getContent();
to
echo $application->handle($_GET['_url'] ?? '/')->getContent();

I hope it will solve your problem.

Hi, jenovateurs.
Thank you...
This really works perfectly.
Although I don't understand what the '??' means symbol because I couldn't find it in the documentation.
Could I have a slight explanation?
One more time. THANKS.

Hi, @tallande,
I'm glad that it works for you.

About the explanation, '??' is a PHP 7 operator called "Null Coalescing Operator".

For more information, you can go to this page : https://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce

The idea is simple, if $_GET['_url'] is empty, take the value '/' or take the value of $_GET['_url'].

@tallande closing this one. Feel free to drop by on discord or forum if you have more questions.

Thanks again, @jenovateurs
You'r right. It's PHP 7

Was this page helpful?
0 / 5 - 0 ratings