Here is the latest in a series of libraries I’ve been releasing which package up some of my often used, cut and pasted code, into reusable modules for myself and others to use.

So here is the companion piece to my previously released Web Services client library, a web services API endpoint library.

Usage

The library allows you to expose a Callable type (function, object method or static function, closure, and call it via a built in Simple Page Handler endpoint that you can attach to a virtual page (e.g. http://example.com/api).

The library will then use reflection to extract the required and optional parameters, and any default values to pass, and then pass them accordingly.

Once the code has run it’ll trigger an event which you should listen to and determine what format to output the results in based on the 'format' parameter. You might want to look at the Simple Template Library to help you here!

I’ve written an example handler that exposes a single API, but feel free to fire over any comments or questions!

» Visit the project on Github…