Re: Phux - High Performance PHP Router

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 7, 2014, at 10:32 PM, Sebastian Krebs <krebs.seb@xxxxxxxxx> wrote:

> 2014/1/7 Lin Yo-An <cornelius.howl@xxxxxxxxx>
> 
> I can provide a router, that is even faster:
> 
> $routes = [
>   '/hello' => ['foo', 'bar']
> ];
> 
> if (isset($routes['/hello']) {
>     do_something($routes['/hello']);
> }
> 
> 
> I couldn't resist :)
> 

Of course you can do that. I can’t stop you.

but your route only works for very simple case. 

Pux can do more complex pattern routing just like Symfony/Routing.

If you’ve read the readme file carefully, you should have knew that Pux can let you define path requirement and default value very easily, so you don’t need to write complex patterns by hands.

for example, the Pux pattern compiler support the slug & requirement feature just like Symfony/Routing, but Pux provides a better performance.

http://symfony.com/doc/current/book/routing.html#adding-requirements



The example below is copied from the README.

use Pux\Executor;

class ProductController {
    public function listAction() {
        return 'product list';
    }
    public function itemAction($id) { 
        return "product $id";
    }
}
$mux = new Pux\Mux;
$mux->add('/product', ['ProductController','listAction']);
$mux->add('/product/:id', ['ProductController','itemAction'] , [
    'require' => [ 'id' => '\d+', ],
    'default' => [ 'id' => '1', ]
]);
$route = $mux->dispatch('/product/1');
Executor::execute($route);


And here comes the example from Symfony/Routing:

use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;

$collection = new RouteCollection();
$collection->add('blog', new Route('/blog/{page}', array(
    '_controller' => 'AcmeBlogBundle:Blog:index',
    'page'        => 1,
), array(
    'page' => '\d+',
)));

return $collection;



> 
> Also (don't know, what others think) I'd only compare the matching, not the setup. Especially because once you use a form of serialized object and for the other you set it up programmatically ;)

it’s not testing setup. if you've checked the dispatch test case (L40-L50 in https://github.com/c9s/router-benchmark/blob/master/code/dispatch.php)

it only calls the dispatch method in the iteration block.

> 
> 
> 
> On Tue, Jan 7, 2014 at 8:46 PM, Lester Caine <lester@xxxxxxxxxxx> wrote:
> 
> > Stuart Dallas wrote:
> >
> >> Tedd Sperling wrote:
> >>>
> >>>> >>This reminds me of an oversea's client I had where they wanted to
> >>>> enter the American market with their Pet Shampoo. I told them they may want
> >>>> to pick a different domain name, but they insisted that they had properly
> >>>> investigated the market and had made their choice of "smellypet.com".
> >>>> >>
> >>>> >>A year later, they contacted me and said they finally understood what
> >>>> I was talking about.
> >>>>
> >>> >
> >>> >FCKEditor is another higher profile example …
> >>>
> >> http://docs.cksource.com/FCKeditor_3.x/Design_and_Architecture/Rebranding
> >>
> >
> > A good documentation of the problem explaining why what seems like a bit
> > of a joke can backfire?
> >
> > I'm of an age where the Windows DDK came on a stack of floppy disks. It
> > was quite irritating to read some of the jokes and fowl language that were
> > spread through the code. Something that would not be allowed these days as
> > we can all review the code bases. Care in the choice of names is even more
> > important these days?
> >
> >
> > --
> > Lester Caine - G8HFL
> > -----------------------------
> > Contact - http://lsces.co.uk/wiki/?page=contact
> > L.S.Caine Electronic Services - http://lsces.co.uk
> > EnquirySolve - http://enquirysolve.com/
> > Model Engineers Digital Workshop - http://medw.co.uk
> >
> > Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> --
> Best Regards,
> 
> Yo-An Lin
> 
> 
> 
> -- 
> github.com/KingCrunch 


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux