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

Annotations Router - Routes with same segments in path

Hi guys, have a bit of an issue here. I have routes like /user and /admin/user, for some reason all requests to /admin/user seem to be routed to /user.

How can I force the annotation router to route /user to app\controllers\UserController.php and /admin/user to app\controllers\admin\UserController.php? I tried using regex in the annotation like @RoutePrefix('/^user') but this fails with an error. All other distinct routes are routed correctly.

Controllers and dir structure: App\Controllers => app\controllers\UserController.php App\Controllers\Admin => app\controllers\admin\UserController.php

edited Feb '20

Ok... so it seems maybe there are reserved keywords for url params? Using annotations router, I had the following:

/ **
 * @RoutePrefix('/namespaces')
class NamespacesController extends Controller
/ **
 * @Get('/{namespace}')
public function loadByNamespaceAction()

I changed the annotation from @Get('/{namespace}') to @Get('/{namespace_name}') and everything worked..

well you can just point the router to the desired controller/action

$router->add("/admin/user", [
  'controller' => 'admin',
  'action'     => 'user'