Created
August 22, 2011 21:31
-
-
Save Javlopez/1163650 to your computer and use it in GitHub Desktop.
Rest implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors', 1); | |
ini_set('error_reporting', E_ALL); | |
/* | |
* | |
* ASI DEBE de SALIR | |
/users/ | |
/users/add | |
/users/javier/delete | |
/users/0015/update | |
*/ | |
Class User { | |
protected $_method; | |
protected $_arguments; | |
private function __construct() | |
{ | |
$method = $this->getMethod(); | |
switch ($method) { | |
case 'GET': | |
break; | |
case 'POST': | |
$arguments = $_POST; | |
break; | |
case 'PUT': | |
case 'DELETE': | |
parse_str(file_get_contents('php://input'), $arguments); | |
break; | |
} | |
} | |
/** | |
* apirun | |
* | |
* This static method run application (API) system | |
*/ | |
static public function apirun() | |
{ | |
new self; | |
} | |
public function getMethod() | |
{ | |
return $this->_method = $_SERVER['REQUEST_METHOD']; | |
} | |
public function fd() | |
{ | |
//["PATH_INFO"] | |
} | |
public function users() | |
{ | |
} | |
} | |
User::apirun(); | |
var_dump($_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; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment