Table of contents:
- What's new
- AMF Overview
- Installation
- Service Browser
- Installation
- Security
- Fundamentals
- Security
- Datatypes
- Class Mapping
- Sessions
- Creating Services
- Getting Started
- Debugging
- Tutorials
- AMFPHP Development
- Development Roadmap
- SVN Access
PHP Error Logs
Fatal errors can be logged in a log file on the web server. In some cases log files are the only way to debug why a service has failed or why AMFPHP is not responding. Production server error logging should be suppressed however development servers and debugging production errors need to have logging enabled.
PHPInfo()
Create a php info file to understand how your environment is configured. Just add a file called phpinfo.php with the below content and place the file in your web servers root directory. Run the script to view all of your environment settings and search for "Loaded Configuration File" to find the path to your php.ini file.
<?php
phpinfo();
?> Finding PHP Error logs
Run the phpinfo script.
Search for "error_log". This will tell you where *your* error_log is located.
Search for "log_errors". This will tell you whether errors are being logged.
Search for "error_reporting". This will tell you what errors are being logged.
If you want to change any of the settings open your php.ini file and search for the same terms.
Enabling Error logs
Open your php.ini file and search for ‘log_errors’. Set to On. Restart your web server. 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 server 500 internal server error and/or 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.
Getting errors without php.ini access
Unless you have your own "dedicated" server, you are most probably sharing the same hardware with a few thousand other "virtual" domains. For this reason, it is all too natural that your hosting provider will deny you access to the system-wide php.ini file. Whatever value you enter there, is going to affect all the virtual domains running on that machine! Production server administers normally have a similar view to changing php.ini values.
If you are not able to edit the php.ini file you may still be able to get error logging working. In the gateway.php file right after the <?php at the start of the file add the following lines.
<?php
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting (E_ALL);
/* rest of file */
?>
You can then use a browser to go to the gateway.php page and in most cases see the error in the browser. If the gateway.php resolves and you still get errors when you call a service you will need to use a Debugging Proxies in order to view the service errors. This may or may not work properly depending on your php installation as your administrator could disable your ability to do this.
Getting errors with .htaccess on apache
.htaccess files allow you to quickly make environment changes to a directory on an apache web server. Adding and removing the .htaccess file allows for a php change without restarting the webserver. The apache configuration does have to allow overriding of options for this to work. The following .htaccess file could be added to the folder on the web server that has your amfphp files. Update the paths to reflect your servers environment. In this example we also have a folder called "logs" for user "username" in a "/home" directory. These may need to be changed for your environment. You will also need to "chmod 777 /home/username/public_html/logs/" the logs directory. Make sure that you remove the .htaccess file and folder when you are done debugging.
ErrorLog /home/username/public_html/logs/error_log
CustomLog /home/username/public_html/logs/access_log common
php_flag display_errors on
php_value error_reporting 6143
php_flag log_errors on
php_value error_log /home/username/public_html/logs/php_log
