#!/usr/bin/env php ' ); // continue if no command given if ( empty( $_reply ) ) { continue; } // check for exit command if ( $_reply == 'bye' ) { die; } // last char $last_char = substr( $_reply, -1 ); // get first cmd $first_cmd = array_shift( array_values( explode( ' ', $_reply ) ) ); // check if we should execute an console controller if ( $first_cmd == 'run' ) { CCConsoleController::parse( substr( $_reply, 4 ) ); continue; } // add semicolon if missing if ( $last_char != ";" && $last_char != "}" ) { $_reply .= ";"; } /* * these commands cannot be used with a var assignment */ $no_return_cmds = array( 'throw', 'echo', ); // catch the return if ( !in_array( $first_cmd, $no_return_cmds ) ) { $_reply = '$_return_data = '.$_reply; } // output buffer ob_start(); // run the command $return = eval( $_reply ); echo $out = ob_get_clean(); // add break if something where outputet if ( strlen( $out ) > 0 ) { echo "\n"; } // dump the return if ( !in_array( $first_cmd, $no_return_cmds ) ) { var_dump( $_return_data ); } }