2017 © Pedro Peláez
 

library restful

A simple Restful library intended for novice developers

image

klaasy1/restful

A simple Restful library intended for novice developers

  • Tuesday, July 19, 2016
  • by klaasy1
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Restful

This is a simple rest base class for beginners in rest, (*1)

Installation

Either run, (*2)

$ php composer.phar require klaasy1/restful: "dev-master"

or add, (*3)

"klaasy1/restful": "dev-master"

to the require section of your composer.json file., (*4)

Usage

use klaasy1\Restful\Restful;

$rest = new Restful();

//This part is your raw data
$myModel = new myModel();
$rawData = $myModel->getRawData();

echo $rest->getData($rawData);

Returns a json response as the default. You can set Accept request header to either return xml or html respone, please note that you need to extend AbtractRestful class and implement encodeHtml and encodeXml functions according to your response data needs and use your RestfulClass instead., (*5)

Example

```php class RestfulClass extends AbtractRestful {, (*6)

//Use this as an example to implement this according to your need
public function encodeHtml($responseData) {

    //Html respose data here
    return $htmlResponse;
}

//Use this as an example to implement this according to your need
public function encodeXml($responseData) {
    //SimpleXMLElement Object
    $xml = new \SimpleXMLElement('<?xml version="1.0"?><root></root>');
    //Build your xml document here
    return $xml->asXML();
}

}, (*7)

The Versions

19/07 2016

dev-master

9999999-dev

A simple Restful library intended for novice developers

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Klaas Rikhotso

rest restful