joaoN1x / koolrest

PHP7 RESTfull easy quick solution based in JSON data exchange
6 stars 1 forks source link

Koolrest

PHP7 RESTfull easy quick solution based in JSON data exchange

calculation and sessio endpoint's are examples to show the potential of this solution

Features

Getting Started

All you need to do to have an end-point working is to create a PHP file in doers/ folder, and call it on the url with the same path of the namespace.

e.g. Nginx

        location / {
                 try_files $uri $uri/ /index.php?$args;
         }
    <?php
    namespace doers;
    class stuff {
        public $return = array("error" => "0", "message" => "");
        public function todo_get($params = array()) : array {
            $this->return['message'] = "I just GET it.";
            return $this->return;
        }
        public function todo_post($params = array()) : array {
            $this->return['message'] = "I just POST it.";
            return $this->return;
        }
        public function todo_put($params = array()) : array {
            $this->return['message'] = "I just PUT it.";
            return $this->return;
        }
        public function todo_delete($params = array()) : array {
            $this->return['message'] = "I just DELETE it.";
            return $this->return;
        }   

_post added to the function will handle POST sent, or _get, or delete... and so on... but if nothing is added, no , that function will handle any inside it.

It can't be easier than this, right? ;)

Follow-up

Next main feature will be to have some constants for https validation, any ideas are welcome.

Further notes

Created by joaovieira.com in Planet Earth, at the Universe.