/** * Register a command * * @return void */ public function register() { $cmd = PHP_Shell_Commands::getInstance(); $cmd->registerCommand('#^p #', $this, 'cmdPrint', 'p <var>', 'print the variable verbosly'); $opt = PHP_Shell_Options::getInstance(); $opt->registerOption('verboseprint', $this, 'optSetVerbose'); }
static function getInstance() { if (is_null(self::$instance)) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; }
<?php @ob_end_clean(); error_reporting(E_ALL); set_time_limit(0); $include_path = get_include_path() . ':' . dirname(__FILE__) . '/lib/PHP_Shell-0.3.1'; set_include_path($include_path); require_once "PHP/Shell.php"; $__shell = new PHP_Shell(); $__cmd = PHP_Shell_Commands::getInstance(); $f = <<<EOF PHP-Barebone-Shell - Version %s%s (c) 2006, Jan Kneschke <*****@*****.**> >> use '?' to open the inline help EOF; printf($f, $__shell->getVersion(), $__shell->hasReadline() ? ', with readline() support' : ''); unset($f); while ($__shell->input()) { try { if ($__shell->parse() == 0) { ## we have a full command, execute it $__shell_retval = eval($__shell->getCode()); if (isset($__shell_retval)) { // WORKAROUND for var_export error "Nesting level too deep - recursive dependency": ob_start(); var_dump($__shell_retval); $dataDump = ob_get_clean(); echo $dataDump; }
public function register() { $cmd = PHP_Shell_Commands::getInstance(); $cmd->registerCommand('#^\\? #', $this, 'cmdHelp', '? <var>', 'show the DocComment a Class, Method or Function' . PHP_EOL . ' e.g.: ? fopen(), ? PHP_Shell, ? $__shell'); }
public function register() { $cmd = PHP_Shell_Commands::getInstance(); $cmd->registerCommand('#^:set #', $this, 'cmdSet', ':set <var>', 'set a shell variable'); }
public function register() { $cmd = PHP_Shell_Commands::getInstance(); if (Prado::getApplication() !== null) { $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]', 'Generate Active Record skeleton for <table> to <output> file using' . PHP_EOL . ' application.xml in [directory]. May also generate [soap] properties.'); } }
public function register() { $cmd = PHP_Shell_Commands::getInstance(); $cmd->registerCommand('#^r #', $this, 'cmdLoadScript', 'r <filename>', 'load a php-script and execute each line'); }
/** * handle the input line * * read the input and handle the commands of the shell * * @return bool false on 'quit' or EOF, true otherwise */ public function input() { $l = $this->readline(); /* got EOF ? */ if (false === $l) { return false; } $l = trim($l); if (empty($this->code)) { $this->verbose = 0; $cmds = PHP_Shell_Commands::getInstance()->getCommands(); foreach ($cmds as $cmd) { if (preg_match($cmd['regex'], $l)) { $obj = $cmd['obj']; $func = $cmd['method']; if (false === ($l = $obj->{$func}($l))) { //quit return false; } if (is_array($l)) { $this->code_buffer = $l; $l = ''; } break; } } } $this->appendCode($l); return true; }