//ini_set('display_errors', 0); // Dependency autoloader spl_autoload_register(function ($class) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $class); require './include/' . $class . '.php'; }); // Get string data input from body input $input = file_get_contents('php://input'); // Parse input into JSON assoc. array $input = json_decode($input, true); // SANITY CHECK: If parse failed, // default to an empty array if (!isset($input) || empty($input)) { $input = array(); } // Get request action variable $request = $input['request']; unset($input['request']); // The rest of this is data needed for the action $params = $input; // Now that everything has been validated, // create client that connects to database $client = new Client(); // Setup RequestManager for any possible requests // for our database client $manager = new RequestManager($client); // Attempt to execute user's request $result = $manager->execute($request, $params); // Echo back the result as a JSON string echo json_encode($result);