RESTifies your web resources (no pun intended)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

RESTify class

an abstract class that 'RESTifies' a resource, function, or class method.


'RESTifies' the function, method or resource that uses it.

  • @access public
  • @param string action
  • @return mixed


a protected method that returns a RURL_mapper object.

RURL_mapper class

used to map RESTful URLs


sets the query property to map.

  • @access public
  • @param array data
  • @return void

Sample Usage:

// ..previous code

$resource = '';

$resource = parse_url($resource);

$request_uri = $resource['path'];

$uri_array = trim(explode('/', $request_uri), '/');


// next code..

maps the query property

  • @access public
  • @param array data
  • @return array

Sample Usage:

// ..previous code
$data = array(

$mapped_data = $this->rurlm->map($data);

// next code..


  'just-another-segment' => Array(
  'category' => 'products',
  'id' => '17'


  • Create an Endpoint class

      class My_Endpoint extends Restify {
        public function onGet($data = null){
          // GET method
        public function onPost($data = null){
          // POST method
        public function onPut($data = null){
          // PUT method
        public function onDelete($data = null){
          // DELETE method
  • Apply the endpoint to a function or method.

      // ..previous code
      // next code..
  • Send some "actions" to the RESTified Resource!

      GET /active_endpoint HTTP/1.1

What are RESTful URLs?

also known as Clean URLs, are purely structural URLs that do not contain a query string and instead contain only the path of the Resource

an example of a clean url

which is equivalent to..

The problem is the global variable $_GET wont recognize /products and /17 as category and id respectively. Restify is capable of mapping these RESTful URLs using RURL_mapper class.

What is an Endpoint class?

You might be confused about the Endpoint Class that I have been mentioning (alot). It is the name I call to classes that extends the Restify Class. It consists of 4 (four) required methods:

  • onGet()
  • onPost()
  • onPut()
  • onDelete()

these methods need only one parameter (though not required) to read the input or query sent by the HTTP request. You can optionally return a value which in turn be passed down to the respective Restify::endpoint() called.

What is a RESTified Resource?

A URI where you can do RESTful requests (GET,POST,PUT,DELETE) and execute respective actions based on the Endpoint Class called within that resource.