Last active
          December 11, 2015 12:38 
        
      - 
      
- 
        Save aaronlifton3/4601562 to your computer and use it in GitHub Desktop. 
    rest ftw bro, zf
  
        
  
    
      This file contains hidden or 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 | |
| public function indexAction() | |
| { | |
| $this->getResponse()->setBody('List of Resources'); | |
| $this->getResponse()->setHttpResponseCode(200); | |
| } | |
| public function getAction() | |
| { | |
| $this->getResponse()->setBody(sprintf('Resource #%s', $this->_getParam('id'))); | |
| $this->getResponse()->setHttpResponseCode(200); | |
| } | |
| public function postAction() | |
| { | |
| $this->getResponse()->setBody('Resource Created'); | |
| $this->getResponse()->setHttpResponseCode(201); | |
| } | |
| public function putAction() | |
| { | |
| $this->getResponse()->setBody(sprintf('Resource #%s Updated', $this->_getParam('id'))); | |
| $this->getResponse()->setHttpResponseCode(201); | |
| } | |
| public function deleteAction() | |
| { | |
| $this->getResponse()->setBody(sprintf('Resource #%s Deleted', $this->_getParam('id'))); | |
| $this->getResponse()->setHttpResponseCode(200); | |
| } | |
| ?> | |
| // clean RESTFUL response: | |
| curl -v http://localhost/v1/foo | |
| curl -v -X GET http://localhost/v1/foo/1 | |
| curl -v -X POST http://localhost/v1/foo | |
| curl -v -X PUT -d '' http://localhost/v1/foo/1 | |
| curl -v -X DELETE http://localhost/v1/foo/1 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment