Skip to content


Subversion checkout URL

You can clone with
Download ZIP
PHP AMF3 extension
Branch: master


AMF3 encoding/decoding extension for PHP


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:
      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:
      Enable class mapping (see the usage constrains below).
      Enable the PHP class autoloading mechanism in the class mapping mode.
      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.


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

make install

This should install the extension to your default PHP extension directory.
If it doesn't work as expected, manually put the target 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:

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.


Project homepage:

Official Adobe AMF3 specification:


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.
Something went wrong with that request. Please try again.