Requirements

You will need a web server and PHP4 ( > 4.3.0 ) or PHP5 installed. We recommend that you test and develop on a local test server.

A fast way to set up your server is to use WampServer if you’re on a Windows machine. Check this blog post for installation guidelines. It also covers running Apache and IIS at the same time.

Installing AMFPHP on your server

Download AMFPHP here . Drop all of the files into a folder in your document root. Many examples and tutorials on the web use the /flashservices folder, so that can be a good choice.

gateway.php

There is a top-level file called gateway.php that you will need to modify in order to get your installation working. This file will set the location of the services you wish to expose, the charset handling (make sure to set it for the appropriate language), the library used for web services, and other very important data. Please follow the instructions inside the file for using these settings and the allowed parameters.

debuggateway.php

The debuggateway.php file is where you will want your services to point to during development. The debug gateway calls the original gateway as though it were Flash itself (that is, using cURL), passes through results or catches any fatal errors and wraps them in an error that is readable to the NetConnection debugger. Note that debuggateway.php will not work without gateway.php: one just calls the other.

The bottom line is that the debug gateway catches fatal errors, solving the godforsaken NetConnection.Call.BadVersion issue that would make it hard to debug errors without access to the error log. There a few caveats though:

  • Sessions won’t work properly under the debug gateway. Using the error log is still necessary whenever sessions are critically involved.
  • cURL must be enabled
  • There is a performance hit associated with using the debug gateway. You should always point to gateway.php for production use.

Testing the installation

Load the gateway.php file through your server; for example, if you are developing locally, you can load http://localhost/flashservices/gateway.php. If you see a prompt asking you to download a file, the installation went well. Otherwise, PHP should output error messages that will help you track down the actual error.

Enabling error logging for Apache and PHP

Fatal errors can be logged in a server log file. This can help you track down hard-to-debug errors when all else fails. Open your php.ini file and search for ‘log_errors’. Set to On. Restart Apache. From now on PHP errors will be logged in the server log file (ie. errors.log). This will aid you tremendously as fatal PHP errors will throw random garbage in the output stream, meaning that you will get a NetConnection.Call.BadVersion error in the NetConnection debugger. When that happens all you will need to do is open the server error log, look at the last error, and fix it.

If you were not able to complete the steps above for enabling error logging because you don't have access to php.ini, you may still be able to get error logging working. In the gateway.php file, before the first include, write ini_set('log_errors', 1);. This may or may not work properly depending on your php installation.

Installing the HTML service browser

Open the browser/config.inc.php file to make the service browser work. From then on you can load it in your browser at the /flashservices/browser/ address. The service browser is useful as a development tool, but you should probably keep it off the server, as it exposes your services.


amfphp.org | Disclaimer | Conditions of use