Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure custom routes in Phalcon?

Tags:

php

phalcon

I just stumbled at Phalcon (PHP framework) and it looked so promising I decided to try it.

I searched in the docs but haven't found anything related to routes in Phalcon. Does somebody know how to create custom routes in this framework or am I supposed to always follow conventions?

If you don't know Phalcon yet you might want to look at these slides to see what it's about.

like image 282
marcio Avatar asked May 22 '12 18:05

marcio


2 Answers

They replied to the request and have just implemented the custom routes, it doesn't look that good right now but here is the reference:

$router->add("/admin/:controller/a/:action/:params", array(
    "controller" => 1,
    "action" => 2,
    "params" => 3,
));

Links:

  • Phalcon custom routing documentation
  • The request for custom routing feature
like image 167
marcio Avatar answered Oct 11 '22 00:10

marcio


I'm pretty sure you'll have to stick with the baseDir/class/method/argument/... convention.

I read the documentation and the source code, and I don't see any hint that would allow you to handle custom routes relying only on the C extension. One possible solution would be to map them in .htaccess.

like image 41
Alix Axel Avatar answered Oct 10 '22 22:10

Alix Axel