A Basic REST Server in PHP

What follows is a very basic REST server that you can use to create basic services. It is meant as a starter for you to use, something you can build other functionality on top of (for example, any security measures). First, let's take a look at the two classes we want to use for our implementation, and then we'll walk through it.

class RestUtilities {     public static function processRequest()     {         $req_method = strtolower($_SERVER['request_method']);         $obj = new RestRequest();         $data = array();         switch ($req_method)         {             case 'get':                 $data = $_GET;                 break;             case 'post':                 $data = $_POST;                 break;

Get Pro PHP Security: From Application Security Principles to the Implementation of XSS Defenses, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.