0

I am new to symfony and php zend

I am building RESTws using symfony 1.x and Zend 1.11.6 and PHP

here is my code :

routine.yml --

api_highConfidenceHash:
  url:    /api/showList.:sf_format
  class:  sfPropelRoute
  param:  { module: api, action: showList}
  options: { model: showListWS, type: list, method: getDeltaList}
  requirements:
    sf_format: (?:json)   

action.class.php --

 public function executeshowList(sfWebRequest $request) {

        require_once 'Zend/Rest/Server.php';
        $server = new Zend_Rest_Server();
        $server->setClass('showList');
        $server->handle();
    }

showList.class.php --

class showList{
      public function getDeltaList($to,$from){
        return json_encode(array('to'=>$to,'from'=>$from);
       }

Calling WS:

http://localost:9000/test_debug.php/api/showList.json?method=getDeltaList&to=1341705600&from=1341100800

output:

<?xml version="1.0" encoding="UTF-8"?>
<showList generator="zend" version="1.0"><showList><response>{"from":"1341100800","to":"1341705600"}</response><status>success</status></showList></showList>

My requirement is to only the json response output without xml tags , i googled a lot but not able to find solution . Could you please suggest me how can i reponse Ws with only json output.

1 Answer 1

3

Why you use Zend_Rest_Server, I think you can make REST webservice without Zend using only symfony.

Here example:

REST webservice with symfony

sfRestWebServicePlugin

About your question. I think that xml return Zend_Rest_Server. You can check question Make Zend_Rest_Server return JSON instead of XML using ZF, and try use answer. But in comment I read that Zend_Rest_Server is only working with XML. You can't decide the ouput format. So, good luck!

Sign up to request clarification or add additional context in comments.

1 Comment

I have skip Zend and used only Symfony by rendering Json directly thanks for references.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.