AltoRouter icon indicating copy to clipboard operation
AltoRouter copied to clipboard

add run function

Open coder966 opened this issue 5 years ago • 9 comments

Hi. I would like to add a run method to start the router. This pattern (of defining the routes and then starting the router) typically exist in all the routers I know of, in Java, React, Node, etc...

This would make the library easier to start with and reduces the boilerplate code in users' code.

We can still let the user control what happens if no matching route found via passing an optional callable to the run method.

coder966 avatar Jul 15 '19 07:07 coder966

Any thoughts ?

coder966 avatar Aug 10 '19 20:08 coder966

I use basically this, $presenter is a configuration array from NEON file:

$alto = new \AltoRouter(); foreach ($presenter as $k => $v) { $alto->map($v["method"], $v["path"], $k, "route_${k}"); if (substr($v["path"], -1) != "/") { $alto->map($v["method"], $v["path"] . "/", $k, "route_${k}_x"); } }

mxdpeep avatar Sep 14 '19 18:09 mxdpeep

Can you give an example of how that would work?

koenpunt avatar Sep 15 '19 07:09 koenpunt

Oh I now see your PR

koenpunt avatar Sep 15 '19 08:09 koenpunt

Oh I now see your PR

check Tesseract LASAGNA project app.php

mxdpeep avatar Sep 17 '19 12:09 mxdpeep

Hello y'all ! Knowing hop usefull os altorouter that i discovered thanks to Grafikart on YouTube via his php lessons, i Would like to Know more With a good tutorial on YouTube

rootoor225 avatar Oct 04 '19 04:10 rootoor225

Tutorial about altorouter on YouTube will ne very usefull. The creators must think to this

rootoor225 avatar Oct 04 '19 04:10 rootoor225

Yes, a person typing typos, humming, hawing and bumbling around in a YouTube video is a great idea. Or even better, written text tutorial that can be quickly fixed and provide the info in a quicker fashion.

ellisgl avatar Oct 05 '19 01:10 ellisgl

Hello everybody ! How am you? I'm well but a little sad. Why? Don't worry. Just because I've spent many times on YouTube to view videos about the best simple and useful routers I ever had used: AltoRouter. I sincerely have heard about it following Grafikart php tutorials videos. However, he didn't spend his time on explaining profoundly this router use. I exhort those of you guys, who are very best on teaching to make videos for teaching us, noobs, step by step, how to use altorouter. It will be very kind and good help.

Thanks and nice day to y'all.

rootoor225 avatar Oct 06 '19 00:10 rootoor225