php - Phalcon 4 documentation controller handler issue

Solution:

I'm not sure of your environment, but this error message appears when you mistake the controller's path or name.

You changed or added the SingleController.php into your controller’s path, right? That isn't on the tutorial.

You should check that your Bootstrap file has access to the controller’s path (or SingleController.php).

Answer

Solution:

I just did the basic tutorial with php 7.4.6 - but with apache webserver:

My Question to you: Did you start your page with http://localhost/ ? so there should not be any "SingleController"-Error to be run into :-/

At the basic tutorial phalcon does not do that much - just putting all steps together for displaying your hello world from your IndexController.php (in app/controllers/ ) because you don't work with models nor views nor templates at all.

if you use apache as well, take care that your DocumentRoot is "[WebProjectDir]/public/" -> if you have apache standard install it could be: "C:\apache\htdocs\public" (Windows Style) and in Apache use unix-style ;)

That could be a bit tricky at the beginning :)

Okay, maybe the Documentation can be corrected at some steps - for example the integration of PHPStorm is quite easyer than shown in video. maybe I'll correct that at some time :)

And now have fun with Phalcon, come back on any questions :)

Answer

Solution:

the issue because the project is not on root folder

the best solution to this issue is reverse every change you made before ( judging by reading some of the comments ) which suggests editing httpd.conf which is not recommended mostly because it is the same as moving the contents of folder single to htdocs/ and this will get your server stuck on one project

now the simple solution:

edit single/public/index.php

change $_SERVER['REQUEST_URI'] to $_GET['_url'] ?? '/'

like so:

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

Source