Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a public API using the Zend Framework?

I have an idea for a web application that would be great if it also had a public API for people to use and interact with. I want people to be able to create their own mobile and desktop applications that interact with the API. Specifically, I want to create an iPhone application that will interact with the API.

I will be building the application with the Zend Framework. I have never created an API, so what do I need to know about creating an API using the Zend Framework? Any tutorials, or advice would be appreciated.

Specifically, I am wondering...If I decide to use XML or JSON as the format, how do I return the data in that format for the client application to use?

Update: I realized that I needed to learn what type of API I wanted to implement. REST and RPC are basically the two different kinds of APIs. REST is the most simple and common, so I have decided to implement a RESTful API.

Update: Here are some resources I've collected so far:

  • Building RESTful Services with Zend Framework - by Matthew Weier O'Phinney
  • Create RESTful Applications Using The Zend Framework
  • Creating a PHP REST API Using the Zend Framework
like image 950
Andrew Avatar asked Jan 01 '10 02:01

Andrew


2 Answers

Have a good look at Matthew Weier O'Phinney's presentation on architecting Ajax apps with Zend Framework, it will probably answer many of your questions.

It's hard to make any specific recommendations, but I would create two modules: one for the web, and one for the API. Both modules would talk to a flexible service layer built on top of your domain models that make it easy to represent your data as both HTML and whatever API format you choose.

like image 162
Bryan M. Avatar answered Nov 07 '22 08:11

Bryan M.


Try out this book, http://aarce.com/resources/ebooks/Pro-Zend-Framework-Techniques.pdf . Chapter 9 explain in details how to implement Restful web-service for a Zend Application.

like image 1
Imwota Avatar answered Nov 07 '22 09:11

Imwota