Difference between revisions of "Sven/PHP"
From Organic Design wiki
(→PHP errors) |
(→MediaWiki profiler: More {{code...}}) |
||
Line 98: | Line 98: | ||
==MediaWiki profiler== | ==MediaWiki profiler== | ||
The article [[MW:How to debug|how to debug]] MediaWiki provides information on setting up the profiler by adding the globals to your LocalSettings.php file; | The article [[MW:How to debug|how to debug]] MediaWiki provides information on setting up the profiler by adding the globals to your LocalSettings.php file; | ||
− | + | {{code| | |
<php> | <php> | ||
/** | /** | ||
Line 136: | Line 136: | ||
$wgDebugSquid = false; | $wgDebugSquid = false; | ||
</php> | </php> | ||
− | + | }} | |
However if you include in an extension; | However if you include in an extension; | ||
+ | {{code| | ||
<php> | <php> | ||
include("$IP/includes/GlobalFunctions.php"); | include("$IP/includes/GlobalFunctions.php"); | ||
wfDebug("This is just testing the debug tracing stuff\n"); | wfDebug("This is just testing the debug tracing stuff\n"); | ||
</php> | </php> | ||
+ | }} | ||
there seems to be no output in the generated log file. | there seems to be no output in the generated log file. | ||
Revision as of 22:51, 5 January 2008
Debugging PHP
Debuggers generally use a W:Stack trace. This can be approximated by using print and die statements in sections of code. The combination of print_r and func_get_args allows you to return an array of args that a function was called with;
Casting an object of an array builds an array of the properties, mapping property names to values. e.g.
outputs;
- Array
- (
- [name] => Fred
- [age] => 35
- )
Introspection
From Sven/Notes, Extension:Fasta.php;
PHP errors
To see PHP errors, add this to the very top of LocalSettings.php:
MediaWiki profiler
The article how to debug MediaWiki provides information on setting up the profiler by adding the globals to your LocalSettings.php file;
However if you include in an extension;
there seems to be no output in the generated log file.
See also
- Debugging
- Documentation
- Deoxygen MediaWiki Documentation
- MW:Manual:Coding_conventions
- MW:Manual:Extensions
- MW:Manual:$wgExtensionFunctions
- Extensions
- Extension:PayPal.php - currently contains debugging
- Resources