News for hackers. Stuff that matters.
Re:Link: A fast and simple PHP Router by leeoniya on Thursday May 29, 2014 @11:57AM (#7816854)
there are so many php routers these days that any "fast" claims should probably be accompanied by benchmarks.

routing is a fairly uncomplicated task and the speed difference will only become apparent at really high loads.

http://c9s.github.io/Pux/

http://auraphp.com/packages/Aura.Router/

http://zaphpa.org/

http://toroweb.org/

https://github.com/dannyvankooten/PHP-Router

https://github.com/symfony/Routing

http://docs.phalconphp.com/en/latest/api/Phalcon_Mvc_Router....

Re:Link: A fast and simple PHP Router by nubs on Thursday May 29, 2014 @12:04PM (#7816894)
This list is missing https://github.com/nikic/FastRoute which is definitely worth looking at.
Re:Link: A fast and simple PHP Router by ams6110 on Thursday May 29, 2014 @01:22PM (#7817362)
I used Epiphany last time I needed something like this. https://github.com/jmathai/epiphany

Note that is more than a router, it's a microframework.

Re:Link: A fast and simple PHP Router by krapp on Friday May 30, 2014 @04:33PM (#7823902)
What would you want a 'minimally viable' microframework to include, in terms of functionality?

This has come up a couple of times in PHP framework and router threads, and i've been wondering what it would look like (it would probably be even smaller than Slim Framework). I've gotten as far as including Composer and a rather barebones router and telling people to just include whatever else they want but I suspect other people would want more.

I find it annoying when frameworks include dependencies I don't want, particularly an ORM or a templating engine, but I understand for a lot of people, that's the point (not having to pick dependencies themselves.)

Re:Link: A fast and simple PHP Router by Nickoladze on Thursday May 29, 2014 @12:45PM (#7817139)
Dont forget µ which is totally a legit router

https://github.com/lastguest/mu

Re:Link: A fast and simple PHP Router by insky on Thursday May 29, 2014 @12:50PM (#7817158)
Which begs the question, how on earth do you choose one?

Edit: as in, which router do you pick and how do you pick one? Choice can lead to decision paralysis.

Re:Link: A fast and simple PHP Router by apsdehal on Thursday May 29, 2014 @01:23PM (#7817369)
Check whats your need, if you are building up much bigger apps go for a fully fledged framework, rest for small apps you can use microrouters , according to your need, each has its own unique features.
Re:Link: A fast and simple PHP Router by icedchai on Thursday May 29, 2014 @02:10PM (#7817677)
For small apps, you don't need a "router", period. Routing is done by the file system and placing .php files in directories!
Re:Link: A fast and simple PHP Router by krapp on Thursday May 29, 2014 @05:15PM (#7818624)
One of the benefits of using a url router is access control - you could have a problem with just letting every file be executable by url, especially if you happen to have a remote file inclusion issue anywhere. With a router you know explicitly what can get invoked and what can't.

Although, doing it without a router is probably always going to be faster.

Re:Link: A fast and simple PHP Router by insky on Friday May 30, 2014 @04:42AM (#7820831)
A late trick I discovered, was that you can configure your php instance to inclued a file with every script. For example the following can be added to .htaccess:

  php_value auto_prepend_file 'before.php'
You can then use that for bootstrapping, front controller and to limit access. Can be a bit clumsy, but it's nicely divorced from simple page controllers.
Re:Link: A fast and simple PHP Router by icedchai on Friday May 30, 2014 @12:14PM (#7822560)
neat! this beats putting an include at the top of each file...
Re:Link: A fast and simple PHP Router by krapp on Friday May 30, 2014 @03:49PM (#7823619)
It certainly does.

I personally would still prefer a router but I know of a project which was written almost entirely in sprawling, procedural PHP that might benefit from this. Although I do wonder what the performance hit would be.

Re:Link: A fast and simple PHP Router by leeoniya on Thursday May 29, 2014 @12:59PM (#7817213)
the fact that it uses the magic __callStatic probably means it's out of the running for "fastest"
Re:Link: A fast and simple PHP Router by kawsper on Thursday May 29, 2014 @01:46PM (#7817534)
I liked Klein.php as well. https://github.com/chriso/klein.php
Re:Link: A fast and simple PHP Router by chime on Thursday May 29, 2014 @03:20PM (#7818058)