@@ -12,8 +12,9 @@ class dependency_manager
12
12
public const DEPXML = "dependencies.xml " ;
13
13
14
14
public static $ log_dump = false ;
15
- static function trace (...$ msgs ) { if (class_exists ("php_logger " )) php_logger::trace (...$ msgs ); else if (self ::$ log_dump ) print_r ($ msgs ); }
16
- static function debug (...$ msgs ) { if (class_exists ("php_logger " )) php_logger::debug (...$ msgs ); else if (self ::$ log_dump ) print_r ($ msgs ); }
15
+ private static function dump_log (...$ msgs ) { if (!self ::$ log_dump ) return ; foreach ($ msgs as $ m ) if (is_string ($ m )) print ($ m ); else print_r ($ m );}
16
+ static function trace (...$ msgs ) { if (class_exists ("php_logger " )) php_logger::trace (...$ msgs ); else self ::dump_log (...$ msgs ); }
17
+ static function debug (...$ msgs ) { if (class_exists ("php_logger " )) php_logger::debug (...$ msgs ); else self ::dump_log (...$ msgs ); }
17
18
18
19
public function __construct ($ fnames = null , $ wdir = null )
19
20
{
@@ -53,7 +54,11 @@ protected function ensure_config()
53
54
@mkdir ($ this ->workingDir , 0777 );
54
55
if (!file_exists ($ this ->workingDir )) throw new Exception ("Cannot secure working folder: $ this ->workingDir " );
55
56
56
- if ($ this ->sources == null ) array ($ this ->default_source ());
57
+ self ::trace ("Sources: " , gettype ($ this ->sources ));
58
+ if ($ this ->sources == null ) $ this ->sources =
59
+ array ($ this ->default_source ());
60
+ self ::trace ("Sources: " , gettype ($ this ->sources ));
61
+ self ::trace ("Sources: " , $ this ->sources );
57
62
58
63
if (is_array ($ this ->sources ))
59
64
foreach ($ this ->sources as $ source )
@@ -69,10 +74,27 @@ protected function load_internal_resources()
69
74
70
75
public function default_source ()
71
76
{
72
- if (file_exists ($ v = ($ this ->workingDir . "/ " . self ::DEPXML ))) return $ v ;
73
- if (file_exists ($ v = (__DIR__ . "/ " . self ::DEPXML ))) return $ v ;
77
+ $ phar = strpos (__FILE__ , ".phar " ) !== false ;
78
+ self ::debug ("dependency_manager::default_source, phar= $ phar " );
79
+
80
+ if (!$ phar ) {
81
+ if (file_exists ($ v = (__DIR__ . "/ " . self ::DEPXML ))) return $ v ;
82
+ if (file_exists ($ v = ($ this ->workingDir . "/ " . self ::DEPXML ))) return $ v ;
83
+ }
84
+
85
+ $ d = $ this ->workingDir ;;
86
+ while (strlen ($ d ) >= strlen ($ _SERVER ["DOCUMENT_ROOT " ])) {
87
+ self ::trace ("default_source, d= $ d " );
88
+ if ($ d == ". " ) break ;
89
+ $ dd = dirname ($ d );
90
+ if ($ dd == $ d ) break ;
91
+ $ d = $ dd ;
92
+ if (file_exists ($ v = ("$ d/ " . self ::DEPXML ))) return $ v ;
93
+ }
94
+
74
95
$ d = realpath (__DIR__ );
75
96
while (strlen ($ d ) >= strlen ($ _SERVER ["DOCUMENT_ROOT " ])) {
97
+ self ::trace ("default_source, d= $ d " );
76
98
if ($ d == ". " ) break ;
77
99
$ dd = dirname ($ d );
78
100
if ($ dd == $ d ) break ;
0 commit comments