Using NetDebug::trace

In addition to the local NetDebug.trace method, you also have a remote NetDebug::trace method available in all of your PHP service classes. It works in exactly the same way as the local one. Tracing generously is a key to effecting debugging with AMFPHP.

We recommend that instead of calling mysql_query directly, you call a function which first traces the SQL, then calls mysql_query, then traces mysql_error. This will speed up development tremendously. Obviously, tracing SQL strings in a production environment is a security risk. On a production server, set the PRODUCTION_SERVER constant to true in gateway.php to disable debug headers and output of NetDebug::trace.

Throwing exceptions in PHP5

You can do preventive error-catching using the new throw mechanism of PHP5. When the gateway executes your method, it is actually in a try catch block. Therefore it will catch any errors you throw at it. It will then transcode this into a Flash error message. The onStatus handler will be called instead of onResult in Flash. From this point you can decide what to do with the error.

Triggering errors in PHP4

If you are still using PHP4, you can use trigger_error in a similar fashion to PHP5 exceptions to get redirect error to the onStatus handler. The error level should be set to a non-fatal level such as E_USER_ERROR or below, else PHP will die(). PHP4 errors don't carry as much information as PHP5 exceptions unfortunately. In addition, as soon as the first error is encountered, all other queud messages will be dropped to give beack the error, unlike what happens with exceptions. Nevertheless it can still be useful.

Native E_ERRORs will be reported to Flash from PHP4 or PHP5. That means in particular if you call mysql_connect or mysql_query and there is an error, you will see that error in the NetConnection debugger.

 

 


© amfphp.org | Disclaimer | Conditions of use