A generic REST Service class Example

class RestFulService { private $supportedMethods; public function __construct($supportedMethods) { $this->supportedMethods = $supportedMethods; } public function handleRawRequest($_SERVER, $_GET, $_POST) { $url = $this->getFullUrl($_SERVER); $method = $_SERVER[‘REQUEST_METHOD’]; switch ($method) { case ‘GET’: case ‘HEAD’: $arguments = $_GET; break; case ‘POST’: $arguments = $_POST; break; case ‘PUT’: case ‘DELETE’: parse_str(file_get_contents(‘php://input’), $arguments); break; } $accept = $_SERVER[‘HTTP_ACCEPT’]; $this->handleRequest($url, $method, … Continue reading