Event-Based AJAX Framework for PHP : Part 5

Posted on June 8, 2008
Filed Under AJAX, JavaScript, PHP |

Articles in this series:

  1. Introduction to the Framework
  2. Problems with Creating an Event Based AJAX Callback Mechanism
  3. JSON data passing
  4. The Scriptifiable Interface
  5. The Remotable Interface

This is the fifth and final part to the PHP AJAX Framework series. In this article, I will explain how to use the Remotable interface and why it was created in the first place.

What’s it for?

In order to use the framework, the classes you create that you would like to call remotely must implement the Remotable interface. Any static methods you create in this class will be accessible from client-side javascript via the framework.

When implementing the Remotable interface, your class must include two methods: PreJsonDecodingJavaScript and PostJsonDecodingJavaScript. They must return strings of JavaScript, but those strings can be empty if you don’t wish to use that functionality.

Why bother?

You might ask, if the implemented interface methods can return empty strings why do I need to do this in the first place? Well the idea of this interface lies more in security than in the functions themselves. By creating this restriction, this framework is guaranteeing that client-side script will not be able to call static methods from classes that do not implement the Remotable interface.

That’s basically it. I hope you enjoyed the series and if you have any further questions about the framework, drop me a note.

Get the Source

Download the PHP-AJAX Framework

Comments

Leave a Reply




Captcha
← Enter these letters.