Пример #1
0
 public function setUp()
 {
     $this->_cmd = \Cli\Execute::singleton();
     $line[] = '<?php';
     $line[] = 'echo "test" ."123";';
     $this->_input = implode(PHP_EOL, $line);
 }
Пример #2
0
 /**
  *
  */
 public function display($console)
 {
     $dispatcher = $console->getDI()->getShared('dispatcher');
     $taskName = $dispatcher->getTaskName();
     $actionName = $dispatcher->getActionName();
     if (!class_exists('\\Cli\\Output')) {
         fwrite(STDERR, "Unable to find Output class" . PHP_EOL);
         return;
     }
     // Get Memory Usage
     $curMem = memory_get_usage(FALSE);
     $curRealMem = memory_get_usage(TRUE);
     $peakMem = memory_get_peak_usage(FALSE);
     $peakRealMem = memory_get_peak_usage(TRUE);
     // Get Time
     $totalTime = microtime(TRUE) - $_SERVER['REQUEST_TIME'];
     $startTime = date('m/d/y h:i:s', $_SERVER['REQUEST_TIME']);
     Output::stdout("");
     Output::stdout(Output::COLOR_BLUE . "--------------DEBUG ENABLED---------------------" . Output::COLOR_NONE);
     Output::stdout(Output::COLOR_BLUE . "+++Overview+++" . Output::COLOR_NONE);
     Output::stdout("task: {$taskName}");
     Output::stdout("action: {$actionName}");
     Output::stdout("total time: {$totalTime} start time: {$startTime} end time: " . date('m/d/y h:i:s'));
     if ($console->isRecording()) {
         Output::stdout("task id: " . $console->getTaskId());
     }
     Output::stdout("hostname: " . php_uname('n'));
     Output::stdout("pid: " . getmypid());
     if ($console->isSingleInstance()) {
         Output::stdout("pid file: " . \Cli\Pid::singleton('')->getFileName());
     }
     Output::stdout("");
     Output::stdout("current memory: {$curMem} bytes " . round($curMem / 1024, 2) . " kbytes");
     Output::stdout("current real memory: {$curRealMem} bytes " . round($curRealMem / 1024, 2) . " kbytes");
     Output::stdout("peak memory: {$peakMem} bytes " . round($peakMem / 1024, 2) . " kbytes");
     Output::stdout("peak real memory: {$peakRealMem} bytes " . round($peakRealMem / 1024, 2) . " kbytes");
     Output::stdout("");
     // Print out Commands
     $commands = Execute::singleton()->getCommands();
     if (!empty($commands)) {
         Output::stdout(Output::COLOR_BLUE . "+++Cli Commands+++" . Output::COLOR_NONE);
         foreach ($commands as $command) {
             Output::stdout($command->command);
             Output::stdout($command->file . "\t" . $command->line . "\t" . ($command->success ? Output::COLOR_GREEN . "Success" . Output::COLOR_NONE : Output::COLOR_RED . "Failed" . Output::COLOR_NONE));
             Output::stdout("");
         }
         Output::stdout("");
     }
     // Print out Queries
     if ($console->getDI()->has('profiler')) {
         Output::stdout(Output::COLOR_BLUE . "+++Queries+++" . Output::COLOR_NONE);
         $profiles = $console->getDI()->getShared('profiler')->getProfiles();
         if (!empty($profiles)) {
             foreach ($profiles as $profile) {
                 Output::stdout($profile->getSQLStatement());
                 Output::stdout("time: " . $profile->getTotalElapsedSeconds());
                 Output::stdout("");
             }
             Output::stdout("");
         }
     }
     // Print out Exceptions
     /*$exceptions = Logger::getInstance()->getAll();
     		if (!empty($exceptions)) {
     			Output::stdout(Output::COLOR_BLUE . "+++Exceptions+++" . Output::COLOR_NONE);
     			foreach($exceptions as $except) {
     				Output::stdout($except->getMessage());
     				Output::stdout($except->getCode() . "\t" . $except->getFile() . "\t" . $except->getLine());
     				Output::stdout("");
     			}
     			Output::stdout("");
     		}*/
     // Print out all included php files
     $files = get_required_files();
     Output::stdout(Output::COLOR_BLUE . "+++Included Files+++" . Output::COLOR_NONE);
     foreach ($files as $file) {
         Output::stdout($file);
     }
     Output::stdout("");
 }
Пример #3
0
 public function cmdAction()
 {
     $cmd = \Cli\Execute::singleton();
     $success = $cmd->execute("whoami", __FILE__, __LINE__, $output);
     Output::stdout("You're running this script under {$output} user");
 }