Difference between revisions of "Sven/PHP"
m (→Logging information to file) |
|||
Line 156: | Line 156: | ||
}} | }} | ||
there seems to be no output in the generated log file. | there seems to be no output in the generated log file. | ||
+ | |||
+ | ==Globals== | ||
+ | {{code| | ||
+ | <php> | ||
+ | $wgOut | ||
+ | OutputPage object for HTTP response. | ||
+ | |||
+ | $wgUser | ||
+ | User object for the user associated with the current | ||
+ | request. | ||
+ | |||
+ | $wgTitle | ||
+ | Title object created from the request URL. | ||
+ | |||
+ | $wgLang | ||
+ | Language object selected by user preferences | ||
+ | |||
+ | $wgContLang | ||
+ | Language object associated with the wiki being | ||
+ | viewed. | ||
+ | |||
+ | $wgArticle | ||
+ | Article object corresponding to $wgTitle. | ||
+ | |||
+ | $wgParser | ||
+ | Parser object. Parser extensions register their | ||
+ | hooks here. | ||
+ | |||
+ | $wgLoadBalancer | ||
+ | A LoadBalancer object, manages database connections. | ||
+ | </php> | ||
+ | }} | ||
==See also== | ==See also== |
Revision as of 12:14, 1 May 2008
Contents
PHP errors
To see PHP errors, add this to the very top of LocalSettings.php:
Debugging PHP
The idea is to debug sections of computer code which are under executional focus, this is considerably easier in an OOP paradigm than a procedural one which uses encapsulation. The class provies certain methods and properties to the code that uses the objects, so outside code does not directly access the data structures of those objects, they do so through the interface.
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;
Logging information to file
From Sven/Notes, Extension:Fasta.php;
Introspection
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.
Globals
See also
- Debugging
- PHP Documentation
- Classes and Objects (PHP 5)
- OOP documentation
- Introspection:Class/Object Functions
- Scope Resolution Operator (::)
- Advanced php debugger
- MediaWiki Documentation
- Deoxygen MediaWiki Documentation
- MW:Manual:Coding_conventions
- MW:Manual:Extensions
- MW:Manual:$wgExtensionFunctions
- Extensions
- Extension:PayPal.php - currently contains debugging
- Online Resources