コード例 #1
0
ファイル: bootstrap.php プロジェクト: xp-runners/main
function bootstrap($cwd, $home)
{
    $result = array('base' => null, 'overlay' => array(), 'core' => array(), 'local' => array(), 'files' => array());
    $parts = explode(PATH_SEPARATOR . PATH_SEPARATOR, get_include_path());
    // Check local module first
    scanpath($result, pathfiles($cwd), $cwd, $home);
    // We rely classpath always includes "." at the beginning
    if (isset($parts[1])) {
        foreach (explode(PATH_SEPARATOR, substr($parts[1], 2)) as $path) {
            scanpath($result, array($path), $cwd, $home);
        }
    }
    // We rely modules always includes "." at the beginning
    foreach (array_unique(explode(PATH_SEPARATOR, substr($parts[0], 2))) as $path) {
        if ('' === $path) {
            continue;
        } else {
            if ('~' === $path[0]) {
                $path = $home . substr($path, 1);
            }
        }
        scanpath($result, pathfiles($path), $path, $home);
    }
    // Always add current directory
    $result['local'][] = path($cwd);
    return $result;
}
コード例 #2
0
 /**
  * Gets base folder
  *
  * @param   io.Folder
  */
 public function setBase(Folder $base)
 {
     $this->base = new Folder($base, '..');
     // Scan base path. FIXME: Refactor this to use lang.ClassLoader
     // instead of duplication its sourcecode here
     foreach (array_filter(explode(PATH_SEPARATOR, scanpath(array($base->getURI()), getenv('HOME')))) as $element) {
         $resolved = realpath($element);
         if (is_dir($resolved)) {
             $this->cl[] = FileSystemClassLoader::instanceFor($resolved, FALSE);
         } else {
             if (is_file($resolved)) {
                 $this->cl[] = ArchiveClassLoader::instanceFor($resolved, FALSE);
             }
         }
     }
 }
コード例 #3
0
ファイル: class.php プロジェクト: Gamepay/xp-framework
if ('cgi' === PHP_SAPI || 'cgi-fcgi' === PHP_SAPI) {
    ini_set('html_errors', 0);
    define('STDIN', fopen('php://stdin', 'rb'));
    define('STDOUT', fopen('php://stdout', 'wb'));
    define('STDERR', fopen('php://stderr', 'wb'));
} else {
    if ('cli' !== PHP_SAPI) {
        trigger_error('[bootstrap] Cannot be run under ' . PHP_SAPI . ' SAPI', E_USER_ERROR);
        exit(0x3d);
    }
}
if (!(include __DIR__ . DIRECTORY_SEPARATOR . 'lang.base.php')) {
    trigger_error('[bootstrap] Cannot determine boot class path', E_USER_ERROR);
    exit(0x3d);
}
$home = getenv('HOME');
list($use, $include) = explode(PATH_SEPARATOR . PATH_SEPARATOR, get_include_path());
bootstrap(scanpath(explode(PATH_SEPARATOR, substr($use, 2) . PATH_SEPARATOR . '.'), $home) . $include);
uses('util.cmd.ParamString', 'util.cmd.Console');
ini_set('error_prepend_string', EPREPEND_IDENTIFIER);
set_exception_handler('__except');
ob_start('__output');
array_shift($_SERVER['argv']);
try {
    exit(XPClass::forName($argv[1])->getMethod('main')->invoke(NULL, array(array_slice($argv, 2))));
} catch (SystemExit $e) {
    if ($message = $e->getMessage()) {
        echo $message, "\n";
    }
    exit($e->getCode());
}
コード例 #4
0
ファイル: web.php プロジェクト: melogamepay/xp-framework
        break;
    case 'cli-server':
        if (is_file($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'])) {
            return FALSE;
        }
        header('HTTP/1.0 500 Internal Server Error');
        $_SERVER['SCRIPT_URL'] = substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], '?#'));
        $_SERVER['SERVER_PROFILE'] = getenv('SERVER_PROFILE');
        define('STDIN', fopen('php://stdin', 'rb'));
        define('STDOUT', fopen('php://stdout', 'wb'));
        define('STDERR', fopen('php://stderr', 'wb'));
        break;
    default:
        header('HTTP/1.0 500 Internal Server Error');
}
ini_set('error_prepend_string', '<xmp>');
ini_set('error_append_string', '</xmp>');
ini_set('html_errors', 0);
// Bootstrap
if (!(include __DIR__ . DIRECTORY_SEPARATOR . 'lang.base.php')) {
    trigger_error('[bootstrap] Cannot determine boot class path', E_USER_ERROR);
    exit(0x3d);
}
// Set up class path
$paths = array();
$scan = explode(PATH_SEPARATOR . PATH_SEPARATOR, get_include_path());
foreach (explode(PATH_SEPARATOR, $scan[0]) as $path) {
    $paths[] = '~' === $path[0] ? str_replace('~', $webroot, $path) : $path;
}
bootstrap(scanpath($paths, $webroot) . (isset($scan[1]) ? $scan[1] : ''));
exit(\xp\scriptlet\Runner::main(array($webroot, $configd, $_SERVER['SERVER_PROFILE'], $_SERVER['SCRIPT_URL'])));
コード例 #5
0
ファイル: web.php プロジェクト: Gamepay/xp-framework
    case 'cli-server':
        if (is_file($_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'])) {
            return FALSE;
        }
        header('HTTP/1.0 500 Internal Server Error');
        $_SERVER['SCRIPT_URL'] = substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], '?#'));
        $_SERVER['SERVER_PROFILE'] = getenv('SERVER_PROFILE');
        define('STDIN', fopen('php://stdin', 'rb'));
        define('STDOUT', fopen('php://stdout', 'wb'));
        define('STDERR', fopen('php://stderr', 'wb'));
        break;
    default:
        header('HTTP/1.0 500 Internal Server Error');
}
ini_set('error_prepend_string', '<xmp>');
ini_set('error_append_string', '</xmp>');
ini_set('html_errors', 0);
// Bootstrap
if (!(include __DIR__ . DIRECTORY_SEPARATOR . 'lang.base.php')) {
    trigger_error('[bootstrap] Cannot determine boot class path', E_USER_ERROR);
    exit(0x3d);
}
// Set up class path
$paths = array();
list($use, $include) = explode(PATH_SEPARATOR . PATH_SEPARATOR, get_include_path());
foreach (explode(PATH_SEPARATOR, $use) as $path) {
    $paths[] = '~' == $path[0] ? str_replace('~', $webroot, $path) : $path;
}
bootstrap(scanpath($paths, $webroot) . $include);
uses('xp.scriptlet.Runner');
exit(xp·scriptlet·Runner::main(array($webroot, $configd, $_SERVER['SERVER_PROFILE'], $_SERVER['SCRIPT_URL'])));