Example #1
0
 public static function init($paths = null, $history_path = null)
 {
     self::$_often = get_defined_functions();
     self::$_often = array_merge(self::$_often['internal'], get_declared_classes());
     if (is_null($paths)) {
         $paths = explode(PATH_SEPARATOR, get_include_path());
     }
     self::$_paths = $paths;
     if (self::_supportedReadline()) {
         readline_completion_function(array(__CLASS__, 'autocomplete'));
         self::$__last = null;
         if (is_null($history_path)) {
             if ($home = getenv('HOME')) {
                 $history_path = $home . '/.pprompt_history';
             }
         }
         if (self::$__history_path = $history_path) {
             readline_read_history(self::$__history_path);
         }
     }
     unset($paths);
     unset($history_path);
     unset($home);
     while (self::$__l = self::_readline(">> ")) {
         if (self::_supportedReadline()) {
             if (is_null(self::$__last) or self::$__l != self::$__last) {
                 readline_add_history(self::$__l);
             }
             if (self::$__history_path) {
                 readline_write_history(self::$__history_path);
             }
         }
         try {
             eval(self::$__l . ";");
             echo "\n";
         } catch (Exception $e) {
             echo $e->getMessage() . "\n";
             echo $e->getTraceAsString() . "\n";
         }
         self::$_vars = get_defined_vars();
         self::$__last = self::$__l;
     }
 }
Example #2
0
<?php

include __DIR__ . '/../init.php';
Pix_Prompt::init();