Live data from Hacker News

Macaw - A Simple PHP Router

github.com

21–30 of 52 posts

Re: Macaw - A Simple PHP Router

#21

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

Errors are now functions!

Re: Macaw - A Simple PHP Router

#22
post #10

http://macaw.co/ Oblivious or on purpose?

The OP has another project called parrot https://github.com/GetParrot/Parrot so I think he just likes parrots and the name is coincidence.

Yep! Macaw will be the future router of Parrot. I'm doing a rewrite.

Re: Macaw - A Simple PHP Router

#25
post #11

If 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.

How does flight compare with klein ( https://github.com/chriso/klein.php )?

klein, bottle, flask .. Am I seeing things ?

Re: Macaw - A Simple PHP Router

#27
post #11

If 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.

I'm a huge fan of silex, I use it as a JSON backend API that fetches from a SOAP API.

Silex and other microframeworks are great for these.

Re: Macaw - A Simple PHP Router

#28
post #13
post #12

Earlier 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.

I've definitely never heard of your project. Not saying this to be mean, just show that not everyone has heard of it.

Re: Macaw - A Simple PHP Router

#29
I like the "slim" approach on LOC, kudos to that. I would point some - IMO - design problems:

# 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

#30
post #13
post #12

Earlier 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.

I have never heard of macaw.co. I think your idea of developers that care about web design is flawed.
Post reply on HN