Proposal for a new extension AMFEXT
| From: | Emanuele Ruffaldi | Date: | Tue, 13 Feb 2007 12:17:13 +0000 |
| Subject: | Proposal for a new extension AMFEXT | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-4502@lists.php.net to get a copy of this message | ||
Hello everybody,
I would like to propose to add a new PECL extension for encoding and decoding ActionScript Messages (AMF) for faster data exchange between PHP and Flash. The extension has already been implemented, tested and integrated
by the amfphp project, and the people SabreAMF are doing the same. If the extension is present amfphp takes advantage of it otherwise it uses the PHP serializer. The idea of this extension is to provide the core
elements of the AMF encoding and decoding while demanding the higher level handling to PHP. The extension has
just two functions amf_encode and amf_decode, while flexibility has been provided by some callback functions that
control how objects are encoded and decoded. Moreover recordsets can be encoded quite efficiently with a specific
callback.
There is an implementation detail that I would like to point out. During encoding I was initially using the smart_str
type for storing the encoding, but it was scaling bad with big data to encode. I've solved the problem with a StringBuilder
data structure that is able to scalable well with data, and also it stores references to PHP string if they are longer than a
threshold, something that happens frequently during encoding. Internally the data structure is made of a list of allocation
blocks, and each allocation block is a sequence of raw datas or references to zval. I don't know if this StringBuilder could
be useful for other uses, in the meanwhile I've packed it as a resource, that can be used independently on AMF encoding.
In particular the StringBuilder can be sent to a stream without flattening into a string.
The extension has been currently published on http://www.teslacore.it/wiki/index.php?title=AMFEXT where it is
possible to obtain details on the encoding and the StringBuilder. I am planning to move the source code into the amfphp
project in SourceForge or better in a new project. The extension is licensed under PHP License Version 3.
Do you think that such extension could be interesting or useful?
Best Regards,
Emanuele Ruffaldi
--
Emanuele Ruffaldi
Computer Engineer - PhD.
Scuola Superiore Sant'Anna di Pisa
PERCRO Lab - Virtual Reality and
Telerobotic Systems Division
via Martiri 11
56100 Pisa - ITALY
Tel.: +39 050 838 980
Fax.: +39 050 883 333
E-mail: emanuele.ruffaldi@sssup.it
Web: http://www.teslacore.it