calculation and sessio endpoint's are examples to show the potential of this solution
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.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule .* index.php?url=$0 [QSA,L]
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
"I just GET it."
If you send a REST PUT call to the same end point you will get "I just PUT it."
It can't be easier than this, right? ;)
Next main feature will be to have some constants for https validation, any ideas are welcome.
Created by joaovieira.com in Planet Earth, at the Universe.