Live data from Hacker News

Macaw - A Simple PHP Router

github.com

1–10 of 52 posts

Re: Macaw - A Simple PHP Router

#2
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");
    });

Re: Macaw - A Simple PHP Router

#4
this is very elegant. i haven't used php (beyond wordpress) in years, so i am sure a lot has changed with all the frameworks which cropped up. one of the things i miss about php was the simplicity of dropping a file into a path and making requests directly to it, no extra dependencies required. i know a lot of people prefer prettier urls, so why not use .htaccess file for mod_rewrite rather than using something like macaw?

nice job on creating a really damn simple interface.

Re: Macaw - A Simple PHP Router

#5
Nice. Php's community have -- with the advent of sane dependency management through Composer, no more PEAR yay! -- move to this small composable library style. I think it's a great thing, using Macaw (or Slim, in my case) plus your business logic modelled as raw, SOLID, tested classes gives you an amazing API to work with,both on the PHP side, and on the network side. I haven't needed to use Symfony for anything new lately,though if I was building a huge app from scratch with a larger team, Symfony is where it's at.

Re: Macaw - A Simple PHP Router

#6
post #4

this is very elegant. i haven't used php (beyond wordpress) in years, so i am sure a lot has changed with all the frameworks which cropped up. one of the things i miss about php was the simplicity of dropping a file into a path and making requests directly to it, no extra dependencies required. i know a lot of people prefer prettier urls, so why not use .htaccess file for mod_rewrite rather than using something like…

.htacess and nginx rewriting breaks down when you need to do more complex stuff, at least if you wasn't to keep things maintainable and clean. Pushing routing like this through to the app side gives a lot more flexibility :)

Re: Macaw - A Simple PHP Router

#7
post #6
post #4

this is very elegant. i haven't used php (beyond wordpress) in years, so i am sure a lot has changed with all the frameworks which cropped up. one of the things i miss about php was the simplicity of dropping a file into a path and making requests directly to it, no extra dependencies required. i know a lot of people prefer prettier urls, so why not use .htaccess file for mod_rewrite rather than using something like…

.htacess and nginx rewriting breaks down when you need to do more complex stuff, at least if you wasn't to keep things maintainable and clean. Pushing routing like this through to the app side gives a lot more flexibility :)

i can see why having route parsing in the code would be useful. especially when dealing with user created urls such as "/user/pplante/profile"

Re: Macaw - A Simple PHP Router

#9
really 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.

Post reply on HN