Sorry, accidentally clicked Send before completing the mail!

Hi. This is an interesting question - something I've recently tackled
myself.

I read through this topic in several of the ZF books to get an idea. I
concluded (rightly or wrongly) that if you want to handle all of the
standard http actions (GET/POST/PUT/DELETE) then it is best to sub-class
your controller from Zend_Rest_Controller. In my case I only want to handle
GET/POST so I decided to sub-class from from Zend_Controller_Action and put
the call to Zend_Rest_Server in an action. So, really within an action
method I just do:

$request = $this->getRequest();
$params['method'] = $request->getParam('action');
$params['request']['object'] = $request;

$restServer = new Zend_Rest_Server();
$restServer->setClass('My_API_Rest_Server');
$restServer->handle($params);

And the My_API_Rest_Server class takes over processing.

Note that I found that I had to send through the request object to access
stuff from it - it seems a bit direct but I couldn't figure out a better way
to deal with that requirement. If anyone knows a better/cleaner way please
say so...thanks.

I'd be interested to hear other opinions too.

Regards,

Narinder.
-- 

 ______________________________________________________
| Narinder Chandi, Director,
| ToolBox Systems Limited, Surrey, England, UK.
| tel : +44 (0)1372 720117, mob : +44 (0)7973 512495
| www      : http://www.toolbox.uk.com
| Skype    : NarinderChandi
| LinkedIn : http://www.linkedin.com/in/toolboxsystems
| Twitter  : @ToolBoxSystems
|______________________________________________________
|         Consultancy * Development * Support
|______________________________________________________

on 30/03/2010 21:03, robert mena at [email protected] wrote:

> Hi,
> 
> What's the correct way to use Zend_Rest_Server with the MVC (i.e
> Zend_Controller_Action)?
> 
> I've read about the Zend_Rest_Route but should I have my Controller inherit
> Zend_Rest_Controller (or  define the index/put/get/post/deleteAction) and
> put the new Zend_Rest_Server() / handle inside a certain action?


Reply via email to