Wanted: content negotiation library
So a while back I wanted to add native support for API versioning to FOSRestBundle. While working on this I began to realize that this would really require supporting proper content negotiation. Note that while there is a spec for how to express the preferences of the client, there is no spec on "negotiating" between what the client wants and what the server has to offer. My current implementation is rather simple .. well simple is probably a euphemism for "incomplete to the point of being more than half wrong". I began to search and didn't really find any decoupled library for PHP that could do the job. I then stumbled over mod_negotiation and thought that it would make a lot of sense to use their algorithm as I simply assumed that it would have gotten a fair bit if scrutiny preventing me from doing something stupid. More over it could also mean that we cut optionally allow users to leverage this apache module instead of our PHP implementation to improve performance. Now that idea sat there for a while until the Drupal guys brought up the topic again. I told them my idea and work began doing exactly this but unfortunately isn't moving forward as quickly as needed to make the December feature freeze of Drupal 8. There are two new people willing to work on this, but its still unclear if things will get ready in time. Since I know we are not the only ones who need this in the PHP community, I am sending this out as a rally cry to work on this together.
Now there are a few efforts in this area already that I am aware of and surely many I am not aware of. Heck maybe the perfect solution already exists out there and someone just as to point it out. First up there is Ben Ramsey's adaptation of an older library called mimeparse which provides at least part of what is needed. There is also an older implementation which is not really nicely decoupled and its using the LGPL which I am not a huge fan of. The Flow3 guys also recently beefed up their support for this, but it is not decoupled either. Finally I am sure that the EngineYard folks also have something inside FRAPI relating to content type negotiation.
Now wouldn't it be great of there would be a modern decoupled library that would prevent a solid implementation of a content negotiation algorithm. Maybe even pluggable to allow other flavors for negotiation as I can for example envision some people caring more about speed than completeness. Now I must admit that my personal plate is quite full with PHPCR and friends but I am willing to help to make this happen. But I am likely the wrong person to drive this. So I am hoping that with this post I can entice someone to step up. Maybe EngineYard wants to take the lead on this along the lines of the sponsorship of the Lithium framework? Heck I am sure the Lithium guys would also love to have something like this! But maybe someone will hear this call for help?