Written by Graham on July 13, 2009

Joël's presentation on Web Services and CakePHP identifies important and interesting points that really demystify both implementation of datasources, and what web services mean for developers trying to take advantages of their offerings.

A Web Service is a defined interface. The interface is made known and public, however the implementation may not be known (and its not really important). The developer should be interested in the data supply and the data returned from the web service.

Various mechanisms are available for communicating with a web service. Such as: RPC, SOA, REST and more.

Much of this presentation covered best practices, better practices, and why people tend to make decisions like implementing components when they really want datasources, as well as implementing datasources, and going about the implementation the wrong way. In the case of web services datasources implementation, curl is presented as a good example of something that works, but a better solution is available through the use of HttpSocket. HttpSocket being one of the CakePHP core libraries provided, allowing a complete implementation of Http communication, extending the CakeSocket class.

Authentication and Authorization options were presented, with specific reference to OpenID and OAuth. Authentication and Authorzation are part of the application flow graph. This means implementation should be at the controller level, and in terms of implementing easily managed pluggable sections of code in cakephp converntions, this means a component.

Data Sources are the closest layer to the actual data. Correct implementation of a data source will allow models to connect and communicate in a transparent fashion, meaning easy access to data in a standard way.

The basics of a datasource should implement the following: __construct, listSources, describe, create, read, update, delete as well as defining $_schema. Some great datasource examples can be seen in the core. When implementing a datasource, to ensure maximum use and compatibility, try to make use of CakePHP libraries such as HttpSocket in the place of curl.

Google Charts was presented as a good example of what should not be implemented as a datasource. The data in this instance is handed by some other data source, and the formatted chart request is sent with an image response supplied. This is more appropriate for a helper than a datasource. Joël mentioned that he has a partial google charts helper that he would be willing to share if someone asked.


Other Articles

CakePHP 2 Application Cookbook
Written by James on August 11, 2014

CakeDC Git Workflow - Working Together
Written by Lubomir on July 31, 2014

Users plugin 2.1.0 released
Written by Florian on July 8, 2014

CakePHP 3.0 is coming
Written by Larry on June 28, 2014

CakeDC Git Workflow - Tips and Tricks
Written by Lubomir on June 24, 2014

Comments plugin 1.3.0 released
Written by Florian on June 17, 2014

The annual CakePHP conference
Written by James on June 12, 2014

Tags plugin 1.6.0 released
Written by Florian on June 4, 2014

CakeDC Git Workflow - An Introduction
Written by Lubomir on May 31, 2014

Search plugin 2.3.0 released
Written by Florian on May 23, 2014

CakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHP CakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHPCakePHP