I am building an application using zend framework.
The question is, how to use the same controller logic of the Zend_Rest_Controller within a non-REST app.
For instance, let's assume twitter was written with Zend Framework. They would probably use the Zend_Rest_controller and Route for their API. However, what would they use for their website (which obviously use the same API logic)? Would they write an entire new application that simply fire REST request? Isn't that overload.
[EDIT]
If web app calls API through some http_client class to get the data, that makes another request to server (it causes performance degrade and slow down the response). I don't want to make another request and want to use the same business logic which is in API.
Thanks,
Venu
New Answer:
I have come up with a pattern that seems to work well. It solves all of your concerns: Here is a scaled down version of what I came up with:
First we need our own controller. This conroller will have a service where by it proxies any action request to the service, if they are not defined:
Now its time for the service. We extend Action Helper Abstract so that:
This will act a go between for the the application and the actual storage of the data.
Now for the interface. This will do the actual work of storing, modifying and returning data. The beauty of using it as an interface is that you can easily implement it no matter what you use for the model layer. I created an abstract Storage that simply has a Zend_Form (for validation) and a Zend_Db_Table for the actual data. but you could also implement it on any object.
Now operation anywhere within your site. Suppose you have an "Customers" service. Inside any controller its as simple as
anywhere else (say a view helper for example):
I hope this helps. It is working well for me.