S
S
Sonic_SE2011-12-24 22:02:52
Zend Framework
Sonic_SE, 2011-12-24 22:02:52

How to organize rest api for a site on zend framework?

There is a site about real estate on Zend Framework. I need to implement the ability to add ads by third-party programs. I decided to make the rest similar to api.
Questions:
- Is it necessary to use a modular structure for implementation?
- How to organize routing to the address "domain.com/rest"?
At the moment, all my efforts end with 'Invalid controller specified (rest)'.
Links to articles and examples are welcome.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sonic_SE, 2012-01-04
@Sonic_SE

Suddenly someone will come in handy:
1. I use a modular structure. rest module for rest-api.
The following lines have been added to application.ini:
resources.frontController.moduleDirectory = APPLICATION_PATH
resources.modules = true
2. Routing for the "domain.com/rest" address. Add a route to bootstrap.php:
protected function _initRestRoute()
{
$this->bootstrap('frontController');
$frontController = Zend_Controller_Front::getInstance();
$restRoute = new Zend_Rest_Route($frontController,
array(), array('rest'));
$frontController->getRouter()->addRoute('rest', $restRoute);
}
That's all for now.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question