xpender / php-amf3

PHP AMF3 extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AMF3 encoding/decoding extension for PHP
========================================

Description
-----------

The PHP AMF3 extension provides two functions to use in PHP scripts:

string amf3_encode(mixed $value [, $options = 0 ])

- Encodes $value into an AMF3 byte-stream.
- On success, returns an AMF3 representation of the value.
- On error, returns FALSE and issues a warning message (the only error case is
  wrong argument count).
- The $options argument is a bitmask of options. The following bit constants
  are available in a PHP script:
    AMF3_FORCE_OBJECT
      Force encoding non-dense arrays as anonymous objects.

mixed amf3_decode(string $amf3 [, int &$count [, $options = 0 ]])

- Decodes $amf3 (AMF3 byte-stream) into a PHP value.
- On success, returns a resulting PHP value.
- On error, returns NULL and issues a warning message.
- If $count is provided, the number of bytes actually read from the string
  will be stored in it (the value of -1 indicates an error).
- The $options argument is a bitmask of options. The following bit constants
  are available in a PHP script:
    AMF3_CLASS_MAP
      Enable class mapping (see the usage constrains below).
    AMF3_CLASS_AUTOLOAD
      Enable the PHP class autoloading mechanism in the class mapping mode.
    AMF3_CLASS_CONSTRUCT
      Call the default constructor of a decoded object's class in the class
      mapping mode.

  WARNING! Class mapping should be used with great care since it can
  potentially lead to a breach in security.


Installation
------------

To install the extension, type the following in the source directory:

phpize
./configure
make
make install

This should install the extension to your default PHP extension directory.
If it doesn't work as expected, manually put the target amf3.so library to
what the 'extension_dir' variable in your php.ini points to.
Add the following line to the corresponding extension section in your php.ini:

extension=amf3.so

To run tests, type:

make test


Usage constraints
-----------------

- PHP NULL, boolean, integer, float (double), string, array and object values
  are fully convertible back and forth to their corresponding AMF3 types.
- AMF3 Date becomes a float value whereas XML, XMLDocument and ByteArray
  become strings.
- In a special case, PHP integers are converted into AMF3 doubles according
  to the specification (see the link below).
- A PHP array is encoded as a dense array when it has ascending integer keys
  that start with zero and have no gaps. An empty array adheres to this rule.
  In all other cases, an array is considered non-dense and encoded as a purely
  associative array to avoid ambiguity.
- When class mapping is disabled (the default), AMF3 objects are returned as
  associative arrays; otherwise, they are represented as objects of the
  corresponding PHP classes.


Links
-----

Project homepage: http://neoxic.me/php-amf3/

Official Adobe AMF3 specification:
http://download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf


History
-------

Version 1.2.1 [18/Mar/2013]
+ Important security fixes
+ Minor fixes (build files, tests, README)

Version 1.2.0 [03/Mar/2013]
+ Option to force encoding non-dense arrays as anonymous objects.
+ Option to perform automatic class mapping in the decoder.

Version 1.1.0 [20/Feb/2013]
+ Support for previously unsupported AMF3 types.
+ Major code revision.
+ License changed from GPL to MIT.

Version 1.0.0 [03/Feb/2010]
+ Encoding/decoding of basic PHP/AMF3 values.

About

PHP AMF3 extension

License:Other


Languages

Language:C 89.7%Language:PHP 10.3%