News for hackers. Stuff that matters.
Re:Toro - a php micro-router with great examples by rickmb on Thursday August 23, 2012 @03:18PM (#4424331)
This illustrates exactly why PHP projects often become such an unmaintainable mess and security hole. This looks like an example collection of PHP worst practices.

I mean, what could possibly go wrong with untestable code and unfiltered input...?

Re:Toro - a php micro-router with great examples by jasonmoo on Thursday August 23, 2012 @03:25PM (#4424371)
Not sure how adding some input filtering and tests would make this an unmaintainable mess..?

The code is actually pretty tight and is optimized for empowering a developer rather than inflating the bumpers of your bowling lane.

Re:Toro - a php micro-router with great examples by andypants on Thursday August 23, 2012 @03:57PM (#4424507)
Untestable code? How is it untestable?

Unfiltered input? You realise that this is a router, right? The only 'input' is the URL path.

I really wish you could be more specific about these 'worst practices' that make this 91-line library an 'unmaintainable mess and security hole'.

Re:Toro - a php micro-router with great examples by skrebbel on Thursday August 23, 2012 @04:13PM (#4424569)
That's not the problem this solves. This is 91 lines of code that solve one problem, routing, and that problem only. You filter input right afterwards.

And how is this untestable, exactly? It's really easy to fake http requests in php-cli from a unit test, for instance. And is there any other way you'd want to test a router than by faking php requests? I somewhat wonder whether the fact that this happens to be PHP biased your judgment.

Re:Toro - a php micro-router with great examples by jakejake on Thursday August 23, 2012 @04:41PM (#4424721)
If anything I find that a router makes your code easier to test. If you're 100% consistent about using the router to obtain user input, then your code is easy to unit test with a mock router. Routers themselves can be easy to test as well.

It's a clean separation of concerns - the router is the only thing that knows about the URL implementation. The rest of the code relies on the router to do that. That's a good practice to me.

What would you would consider "best practice" in place of a router?