C PHP M4
Latest commit fb58fa3 Nov 24, 2016 @neoxic Version 2.0.1 [2016-11-24]
+ Fix $a["123"] (number as a string key) look-ups
Permalink
Failed to load latest commit information.
tests + Rename: tests/stress.phpt -> tests/amf3.phpt Aug 29, 2015
LICENSE Version 2.0.0-beta1 May 12, 2016
README Version 2.0.1 [2016-11-24] Nov 24, 2016
amf3.c
amf3.h Version 2.0.0-beta1 May 12, 2016
amf3_decode.c Makeup Nov 22, 2016
amf3_encode.c Version 2.0.0-beta1 May 12, 2016
config.m4 + Fix build files Mar 5, 2013
config.w32 + Fix linefeed in config.w32 Mar 5, 2013
php_amf3.h Version 2.0.1 [2016-11-24] Nov 24, 2016

README

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-indexed 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 an indexed 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-indexed 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 returned as objects.


Links
-----

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

Official Adobe AMF3 specification: http://www.adobe.com/go/amfspec


Release history
---------------

Version 2.0.1 [2016-11-24]
+ Fix $a["123"] (number as a string key) look-ups

Version 2.0.0 [2016-06-23]
+ PHP-NG (PHP7) support

Version 1.2.3 [2014-10-19]
+ Support for previously unsupported AMF3 types
+ Error reporting fixes

Version 1.2.2 [2013-08-31]
+ Minor error reporting fixes

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

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

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

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