-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPharMain.php
More file actions
56 lines (53 loc) · 1.6 KB
/
PharMain.php
File metadata and controls
56 lines (53 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
//## CRF - This file Copr. 2015 Nexus Systems Incorporated - Licensed as per OSS MIT##
//@todo check argv[0] to see what called us
if (class_exists('Phar') && Phar::running(false))
{
//get pharname
define('PHAR_PATH', Phar::running(false));
define('PHAR_NAME', basename(PHAR_PATH));
define('APP_BASE_DIR', 'phar://'.PHAR_NAME);
}
//Use non-ignorant autoloader
// because phars are a case affected by phpbug #49625
if (!function_exists('_SHIM_MATCH_CLASSFILE_ASIS_LOADER'))
{
function _SHIM_MATCH_CLASSFILE_ASIS_LOADER($class)
{
$aPaths=explode(PATH_SEPARATOR, get_include_path());
if('\\' !== DIRECTORY_SEPARATOR)
{
$class=str_replace('\\', DIRECTORY_SEPARATOR, $class);
}
$aExts=array_reverse(explode(',', spl_autoload_extensions()));
foreach ($aPaths as $sBasePath)
{
foreach($aExts as $ext)
{
$cpath=$sBasePath.DIRECTORY_SEPARATOR.$class.$ext;
if (is_readable($cpath))
{
require_once $cpath;
return true;
}
}
}
return false;
}
spl_autoload_register('_SHIM_MATCH_CLASSFILE_ASIS_LOADER');
}
//this main file does run in the same context as the stub,
//but after ::mapPhar() and ::interceptFileFuncs()
//elsewhere please use APP_BASE_DIR
// require_once 'src/Common.php'; // but this is library code....
// if('cli' == PHP_SAPI || 'embed' == PHP_SAPI)
// {
// require_once 'executive/wacc.php';
// return ConsoleMain($argc, $argv);
// }
// else // 99% sure we're in a web context
// {
// require_once 'WebMain.php';
// return WebMain();
// }
//and we're done. HaltCompiler gets called shortly after now