We’ve been tossing the idea of plugins for AMFPHP around, and so here’s what come of it. Please share your thoughts on this. Note: this is a copy of a mil I’ve sent to the amfphp-cvs mailing list

Why?
People who want to contribute to the AMFPHP community currently mst have their contribution vetted by me. Not only am I a poor judge, but I’m also lazy. So the idea is to provide a system where someone who has a cool idea can push it to the community and let the community decide.

Design Goals
Flexibilty, extensibilty, simplicity, convention over configuration

How (global design)?
I’ve looked around a bit, and what seems to work elsewhere and that I quite like is a system of hooks. The idea is that at certain points in the execution of the script the possibility is given to the plugins to interact with the data flow. Here’s a simple example: Your plugin wants to add a service to those available in the usual “services ” folder. When the gateway tries to direct a service call, instead of just routing it to the services folder, it can ask the plugins first if they have a matching service.

How (technical specifics)?
There will be a new “plugins” folder in amfphp. Each plugin will consist at the very least of a subfolder and an index.php. When called this index.php will register for all needed hooks. To continue with the example, the index.php will register a function “addMyService” for the hook “LIST_SERVICES”. When LIST_SERVICES is called by the gateway, the plugin’s “addMyService” function will be called, and it will return the path to the plugin’s service.

What about plugins for the service browser?
The plugin registers for the hook GET_SERVICE_BROWSER_PLUGINS, and naturally takes the opportunity to add a nearby SWF.

That’s all for now. I know it’s a bit sketchy, but once we get the basics down I’ll flesh this out.
Ariel

Pin It