legacy page.
Argo
Argo is a remote method call gateway for calling PHP methods from JavaScript.
Overview
Argo is yet another AJAX framework. Specifically, it is yet another system for remote method calls. But it has several features I couldn't find in other such toolkits.
Benefits
Here are some good reasons for using Argo.
- Argo uses JSON as its internal data format,
which provides two benefits:
- Type is automatically preserved on any arguments passed to and returned by the server-side method, and
- The communications are extremely lightweight.
- None of Argo's JavaScript is dynamically generated. It is all loaded from a static external file. This allows you to easily put the client and server in separate documents if you want to.
- Multiple method calls being posted to a single URI can be queued up and then sent together in one HTTP request.
- Exceptions and debugging messages from the server-side method can be sent, in customizable ways, back to the client for processing in JavaScript.
- Its object-oriented design promotes better organization and prettier code.
Drawbacks
Here are the side-effects of the above benefits.
- Its complexity can be frustrating for people who want to do simple tasks simply.
Because it doesn't dynamically generate JavaScript wrapper functions the way some AJAX toolkits do, calling the remote methods doesn't look quite as natural as you might want them to.
However, I'm playing around with an optional way of exporting these dynamic wrapper functions, so be on the lookout.
What Argo Is and Is Not
Argo is a connector between the JavaScript and PHP parts of a single web application. It lets JavaScript seamlessly and naturally call PHP methods and receive the return values.
Argo is not for publishing server-side methods as web services. For this reason, it does not provide a directory of available methods. It is a connector for allowing you to call methods you already know about. Your JavaScript should have no reason to ask what methods are available.
Also, even though it uses JSON for remote method calls, Argo does not attempt to implement JSON-RPC, which is ill-fitted for HTTP.
Usage
I'm in the process of writing a more formal set of documentation. It will go here when it's done. For now though, there's just the tutorial:
Dependencies
- PHP 5.1.0 (5.2.0 recommended).
- HttpTerminal.
- A JSON library for PHP, either:
- PHP-JSON (recommended, included with PHP 5.2.0),
- Services_JSON, or
- Any other one, with a little extra work.
- JSON in JavaScript.
- A web browser that supports XMLHttpRequest.
Download
Argo is distributed under the terms of the GNU General Public License. A copy of the license is included in the download.
- Argo.tar.gz - Contains JavaScript and PHP source code.