Download the PHP package jayc89/slim-json-api without Composer
On this page you can find all versions of the php package jayc89/slim-json-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jayc89/slim-json-api
More information about jayc89/slim-json-api
Files in jayc89/slim-json-api
Package slim-json-api
Short Description Slim extension to implement fast JSON API's
License GPL 3.0
Homepage https://github.com/jayc8/slim-json-api
Informations about the package slim-json-api
slim-jsonAPI
This is an extension to the SLIM framework to implement json API's with great ease.
Installation
Using composer you can add use this as your composer.json
Usage
To include the middleware and view you just have to load them using the default Slim way. Read more about Slim Here (https://github.com/codeguy/Slim#getting-started)
.htaccess sample
Here's an .htaccess sample for simple RESTful API's
example method
all your requests will be returning a JSON output.
the usage will be $app->render( (int)$HTTP_CODE, (array)$DATA);
example Code
example output
Errors
To display an error just set the error => true
in your data array.
All requests will have an error
param that defaults to false.
You can optionally throw exceptions, the middleware will catch all exceptions and display error mensages.
routing specific requests to the API
If your site is using regular HTML responses and you just want to expose an API point on a specific route, you can use Slim router middlewares to define this.
middleware
The middleware will set some static routes for default requests. if you dont want to use it, you can copy its content code into your bootstrap file.
IMPORTANT: remember to use $app->config('debug', false);
or errors will still be printed in HTML