Archive for May, 2009

ext/scream functionality without ext/scream

There were some rumors recently about Gopals ext/scream. This extension disables the @ operators and therefore makes all errors visible. If you want to use the extension you have to build the extension and restart your PHP modules so that the extension is loaded.

But there is a more elegant to get the same behavior. Using DTrace and recent OpenSolaris 2009.06 we are able to use the php:::error probe to get all error messages. Unlike the PHP extension we do not need to restart our PHP. We are also able to just temporarily look into the errors of all running PHP processes. Here is the DTrace script:

#!/usr/sbin/dtrace -s

php*:::error {
printf("Error \"%s\" in file %s line %d\n", copyinstr(arg0), copyinstr(arg1), arg2);

This will display all errors that occur. There is also a php:::exception-thrown probe which can provide nearly the same data for exceptions instead of errors.