Probably shouldn't be "hard" coding the scheme (http). Check $_SERVER['https']. You can make sure this fastcgi param exists with a simple directive in nginx (fastcgi_params): fastcgi_param HTTPS $https if_not_empty; Also, the 404 route, should be able to be defined as a custom function: Macaw::fourofour(function() { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); header("Status: 404 Not Found"); });
Macaw - A Simple PHP Router
21–30 of 52 posts
Re: Macaw - A Simple PHP Router
#22Re: Macaw - A Simple PHP Router
#23really nice. if I had any suggestions at all though it would be to have the 404 route actually return the 404 header (or have a way to specify headers with routes), and also have it handle https.
Re: Macaw - A Simple PHP Router
#24Re: Macaw - A Simple PHP Router
#25Re: Macaw - A Simple PHP Router
#26It's... 87 lines of PHP?
Re: Macaw - A Simple PHP Router
#27If you want something with more features but still just as simple, check out: http://flightphp.com/ I'm using it to make a JSON backend API and it works great.
Silex and other microframeworks are great for these.
Re: Macaw - A Simple PHP Router
#28Earlier quoted context omitted.
two people can't name their thing after the same bird?
Well when one thing has had a viral kickstarter campaign, been on every Tech blog, and its name known by just about every developer who cares about web design. Then to hear something else named the exact same name around the same time feels kinda weird.
Re: Macaw - A Simple PHP Router
#29# Static attributes and methods. Are they really needed? They are difficult to test and predict, specially the public attributes.
# The "echo"s on routes. Since every route is a method (encapsulated by one), this behavior could be easily avoided (easier to test and control). You are already using callables, you can easily test (and run) matching routes to execute any callable until a stream is given (on Respect/Rest we learned what a powerful feature it is).
# Lack of tests. Although low LOC, there is much happening, specially on the "dispatch" method (it would be awesome to know through tests what the If's/Else's actually do and prevent).
# Why (as mentioned before) the error header do not provide a proper HTTP header!? It would also be nice to provide two different error routes: one for client errors (404: not found, forbidden) and another to server errors (HTTP/1.1 500 Server Error).
A suggestion (we've been talking a lot on Respect/Rest) is to implement the URI Template (RFC 6570) for matching routes and hydration of parameters (something macaw lacks but i like using the PHP way of $_GET, $_POST and filter_input()). With a component dealing nicely with URI Templates many projects would benefit from it.
Re: Macaw - A Simple PHP Router
#30Earlier quoted context omitted.
two people can't name their thing after the same bird?
Well when one thing has had a viral kickstarter campaign, been on every Tech blog, and its name known by just about every developer who cares about web design. Then to hear something else named the exact same name around the same time feels kinda weird.