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

Possible Bug with Routing?

This happens to me every few months with Phalcon and I forget about the problem and end up wasting so much time debugging it.

Let's say I have the following configuration.

  • Not using modules
  • A "controllers" and "views" directory
  • Using the default Router
  • Phalcon 3.0

Let's say I have two files in "controllers":

  • IndexController.php
  • TestController.php

Each of these both have two actions, let's say "indexAction" and "secondAction"

Now, If I visit the following url's:

  1. https://localhost/index/index
  2. https://localhost/index/second [This one doesn't work. It instead goes to index/index]
  3. https://localhost/test/index
  4. https://localhost/test/second

Is there a known problem with having "index" as your handler (or controller) in which it is not able to access any of the actions of that controller?

Another interesting thing is that when I run my unit tests using $app->handle('index/second'), it does seem to hit the right action.

What you mean this one doesn't work ?

I've added a comment to the original post. But basically, when you go to index/second, it goes to index/index

Well. What webserver you are using first - provide config from apache or nginx for this host. If using php built-in server then try nginx/apache. Maybe something wrong with your configuraton.

Another solution might be to use:

$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);

After doing some research, I came upon this link: https://forum.phalcon.io/discussion/2061/unable-to-call-index-controller-s-actions+&cd=1&hl=en&ct=clnk&gl=ca

The solution was putting the following in my .htaccess file:

Options +FollowSymLinks -ExecCGI -Includes -IncludesNOEXEC -Indexes -MultiViews -SymLinksIfOwnerMatch

Well, i see this first time :D Just start using nginx instead of apache ;)