3 * PHP lacks an interactive mode, but this can be very helpful when debugging.
4 * This script lets a command-line user start up the wiki engine and then poke
5 * about by issuing PHP commands directly.
7 * Unlike eg Python, you need to use a 'return' statement explicitly for the
8 * interactive shell to print out the value of the expression. Multiple lines
9 * are evaluated separately, so blocks need to be input without a line break.
10 * Fatal errors such as use of undeclared functions can kill the shell.
12 * To get decent line editing behavior, you should compile PHP with support
13 * for GNU readline (pass --with-readline to configure).
16 * @ingroup Maintenance
19 $wgUseNormalUser = (bool)getenv('MW_WIKIUSER');
21 $optionsWithArgs = array( 'd' );
24 require_once( "commandLine.inc" );
26 if ( isset( $options['d'] ) ) {
29 $wgDebugLogFile = '/dev/stdout';
33 foreach ( $lb->mServers
as $i => $server ) {
34 $lb->mServers
[$i]['flags'] |
= DBO_DEBUG
;
38 $wgDebugFunctionEntry = true;
42 if ( function_exists( 'readline_add_history' )
43 && function_exists( 'posix_isatty' ) && posix_isatty( 0 /*STDIN*/ ) )
51 $historyFile = "{$_ENV['HOME']}/.mweval_history";
52 readline_read_history( $historyFile );
55 while ( ( $line = readconsole( '> ' ) ) !== false ) {
57 readline_add_history( $line );
58 readline_write_history( $historyFile );
60 $val = eval( $line . ";" );
61 if( is_null( $val ) ) {
63 } elseif( is_string( $val ) ||
is_numeric( $val ) ) {