Requests for comment/PHP Virtual REST Service

Problem description
Current PHP bindings to HTTP web services lack some conveniences and features:


 * authentication needs to be performed manually per request rather than being configured per services accessed
 * there is no generic way to load balance or fail over backends to avoid single points of failure
 * multiple requests can't easily be performed in parallel

With more web services in use in the backend infrastructure it might be worth spending some time on optimizing the way we access web services from PHP.

Strawman API design
This is a very early strawman API design that maps fairly easily onto a curl_multi based implementation:

Backend registration
The generic store has a registry of prefixes to storage backends. Matching happens longest-prefix first. Example:

Backends can be HTTP-based, but can also be transparently mapped to local PHP classes or other protocols. The path-based namespace presents a simple and unified API and avoids the need for many different classes. New backend features or backends can be added without a need to upgrade the client bindings. Bulk operations can be performed across several backends.

Tasks to be handled by backend implementations:


 * authentication: retrieve auth key, add auth headers etc
 * URL and more generally request munging

An idea is to pass the full request information to each backend for general munging.