Category → wsf/php

RESTful PHP Web Services

If you’ve read the architectural notes about RESTful applications and want to get your hands dirty writing one quickly, RESTful PHP Web Services by Samisa Abeysinghe is a book you should read. It starts with an introduction to what REST is and surrounding technologies. Since many web applications today expose their functions as RESTful APIs, you’ll be better prepared to play around with these after reading this book. Also a simple application that explains all the necessary functions for developing a RESTful application is discussed.

Introduction gives the reader a head start about what REST is all about and tools needed to play with RESTful web services. Then PHP libraries and function used for talking to a REST service is explained. How CURL is used to send requests with various HTTP verbs such as GET, POST, PUT, DELETE are explained with examples. After getting an XML response from a service, PHP libraries for manipulating XML and extracting parts of data you want is illustrated with samples. One could directly copy and paste these codes and try it out as they read along. Then the author goes on to explain how to use Flickr with PHP using CURL. If you’ve been using a high level library that insulate the lower level details, this example shows some of the basic API calls and how to use them.

After explaining a mashup of BBC news feed and Yahoo search API, author explains how to design RESTful services. This is carried out along with the simple but complete example of a library system. How to provide a service as well as consuming that using PHP and CURL is explained with complete code samples. Then he explains how to design the same thing using the Zend Framework.

The book concludes with a chapter dedicated to debugging REST web services. Using the TCPMon tool to capture messages and look for possible errors. The chapter ends with a set of best practices that everyone should be aware of if you do any programming with REST web services. The book also mentions WSF/PHP as an advanced framework providing many more functionality amidst of acting as a REST framework. I highly recommend this book if you’re a PHP programmer waiting to get your hands dirty designing RESTful applications. To whet your appetite here’s a sample chapter from the book about designing and implementing resource oriented clients. Enjoy!

Enterprise PHP

Samisa has written a nice post about using PHP in the enterprise. A commenter there argues that he don’t use PHP because it’s a dynamically typed language. It’s somewhat true that if you’re coming from a statically typed language background you’re stormed with so many questions and wonder possible nightmares of using one. Once you start learning a language and understand how programs are suppose to be written in that language most of these problems go away.

For all these years, it has only been Java/.Net programmers who has been enjoying the luxury of service oriented architectures. These folks understand the value of building a business functionality as a service or exposing an existing functionality as a service. PHP programmers have been building their web based programs happily without having to know what services mean. People in the PHP community has tried to bring Web services into the language with varying degrees of success. These are very courages and thoughtful efforts. But if you analyze them objectively you’ll see that many of these libraries doesn’t contain that much of features in order to build/integrate an application with an existing enterprise app.

What WSF/PHP has done is lower the bar of building PHP applications that can fit with existing applications in an enterprise written in Java/.Net or whatever the language that might be. Also, it has enabled ability to integrate existing PHP applications to your other enterprise applications.

One strong reason companies have embraced developing applications in Java is that so their data will not be isolated from rest of the enterprise data. In the past having a PHP application inside your company might have been frowned upon because it doesn’t make sense to have information which is isolated from all the other applications in the company. This is why most organizations invest in an ERP for example. But now, this has become a non issue. If you’re using open standards inside your enterprise to communicate/integrate applications, using WSF/PHP, you can integrate or extend services seamlessly with rest of your enterprise services.

Yet another WAMP

Among the large number of WAMPs on the net there’s room for yet another one. SOAWAMP. This one’s sole purpose is to bundle WSF/PHP together and provide a platform for developing Web services right out of the box. So you don’t have to go through the README and install WSF/PHP on your Windows machines. In fact, you don’t have to install anything. This is all thanks to the excellent work of The Uniform Server team.

If you have been reading on the web how bulky and complex it is to develop WS-* applications, and how complex it is to get features like WS-Security, MTOM etc… download SOAWAMP and run the samples related to those sections and see, go through the source and see for yourself how simple the API is. As for all the other folks who still blather without looking … Feh.

SOAWAMP is a combination of The Uniform Server and WSF/PHP. The latest release of SOAWAMP bundles the most recent version of WSF/PHP. Download. Unpack. Double click. Have fun!