1

Is there some kind a engine for Json in the Zend framework, What I mean is some abstraction that all the Json (ajax) responces go through ? in other words some class to controll all the Ajax calls?

2 Answers 2

4

Zend_Json_Server - JSON-RPC server might do what you are looking for:

Zend_Json_Server is a » JSON-RPC server implementation. It supports both the » JSON-RPC version 1 specification as well as the » version 2 specification; additionally, it provides a PHP implementation of the » Service Mapping Description (SMD) specification for providing service metadata to service consumers.

Apart from that, there is also Zend_JSON, that

provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP. […] In addition, Zend_Json provides a useful way to convert any arbitrary XML formatted string into a JSON formatted string. This built-in feature will enable PHP developers to transform the enterprise data encoded in XML format into JSON format before sending it to browser-based Ajax client applications.

Also see these articles by

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

5 Comments

+1, Zend_Json_Server is what you want. I wrote a blog post about it yesterday, coincidentally: ciaranmcnulty.com/blog/2010/03/…
@Ciaran Nice. I was trying to find a decent article on Json_Server, so I added yours to the answer.
Thanks seniors -- as always valuable responses
btw I am really confused (and my Flexibility part is bugging me) ok lets say I have a form User Registration. I use it from JS. with a load(just get the html code) and it uses XMLhttp request right, then I need this for for Ajax again Xmlhttp request, but here I have to echo out JsonEncoded info and turn off View renderer, (problems starting) and after while I will need it with just regular request. so the dilemma is to handle it in a flexible way or have bunch of actions for different requests, but this way it is same hard coded . anyhow I am just confused - will appreciate ur advice
@simple please go through the two linked articles. If there is any questions then, open another question. The Comment Sections is akward for this.
0

Your question is a little vague and could be interpreted in two ways.

a. You are just trying to serve ajax actions through your controllers.

This is pretty simple to achieve using the context switch action helper

b. You want to serve JSON responses via an API, whether it be to use internally or externally.

If that is the case, Zend_Rest_Controller is probably the direction you want to go in.

I hope this helps.

Comments

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.