7

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.

Tim Post
  • 33,371
  • 15
  • 110
  • 174
marcio
  • 10,002
  • 11
  • 54
  • 83
  • 2
    I looked at their docs. Looks like they currently only have Controller/Action routes. See here http://phalconphp.com/api/class/Phalcon_Router_Rewrite. I was going to look at the code, but I realized the code was written in C, which I'm not too fluent in. See here: https://github.com/phalcon/cphalcon/blob/master/release/phalcon.c – Gohn67 May 26 '12 at 05:02
  • 1
    I would love to know C and don't need to ask this question here, but it's not an option at moment. – marcio May 28 '12 at 03:28

2 Answers2

4

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:

marcio
  • 10,002
  • 11
  • 54
  • 83
  • 1
    I'd love it if that didn't have to go in the bootstrap, but it's adequate enough for what I needed. The tests I did show the regex based routing to not be any faster or slower than just using `.htaccess` (I was hoping for faster, but not slower is perfectly acceptable). – Tim Post Sep 03 '12 at 01:16
  • 1
    I actually just [suggested](http://phalcon.uservoice.com/forums/154026-general/suggestions/3127696-give-more-publicity-to-the-phalcon-tag-on-stack-) that they give more publicity to this tag. Finding what you need in the documentation is rather taxing. – Tim Post Sep 03 '12 at 01:35
2

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.

Alix Axel
  • 151,645
  • 95
  • 393
  • 500
  • Thanks @Alix, you're right. I also created a request for this feature and they responded really fast: http://phalcon.uservoice.com/forums/154026-general/suggestions/2884092-custom-routing – marcio May 29 '12 at 20:44
  • @marcioAlmada: That's good to know, Falcon looks pretty slick. =) – Alix Axel May 29 '12 at 21:12