Introduction to using SabreAMF with Flex

Wil wrote a pretty good introduction to using SabreAMF with flex. He's making use of the Zend autoloader to load the classes. If you're new to SabreAMF, this might be a good starting point.

He also mentions its best to set display_errors to 0, to suppress PHP errors. I personally prefer re-throw all PHP errors as exceptions using the following class:

<?php

    /**
     * This is a default exception wrapper for PHP errors.
     * This allows you to deal with PHP errors as exceptions (using try..catch blocks etc..)
     *
     * @uses Exception
     * @package Sabre
     * @subpackage PHP
     * @version $Id: Exception.php 733 2007-05-15 22:04:52Z evert $
     * @copyright Copyright (C) 2007 Rooftop Solutions. All rights reserved.
     * @author Evert Pot (http://www.rooftopsolutions.nl)
     */
    class Sabre_PHP_Exception extends Exception {

        /**
         * __construct
         *
         * @param string $message
         * @param string $code
         * @param string $file
         * @param int $line
         * @return void
         */
        function __construct($message,$code=false,$file=false,$line=false) {

            parent::__construct($message,$code);
            $this->file = $file;
            $this->line = $line;

        }

        /**
         * Register this class as an error handler
         *
         * @return void
         */
        static function register() {

            set_error_handler(array('Sabre_PHP_Exception','handleError'));

        }

        static function unregister() {

            restore_error_handler();

        }

        /**
         * handleError
         *
         * @param string $code
         * @param string $message
         * @param string $file
         * @param int $line
         * @return void
         */
        static function handleError($code,$message,$file,$line) {

            if (!$code) return;
            throw new self($message,$code,$file,$line);

        }

    }

?>

Simply call Sabre_PHP_Exception::register();, and you're off..