Process/Php7.php
[Pman.Core] / Process / Php7.php
index f55be90..8733aa2 100644 (file)
@@ -22,33 +22,57 @@ class Pman_Core_Process_Php7 extends Pman
             die("CLI only");
         }
     }
-
+    
     function get($base, $opts = array()) 
     {
-        $dir = array($this->rootDir);
-        $cls = array();
+        set_error_handler(function ($errno, $errstr, $errfile, $errline ){
+//            throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
+            print_r(array(
+                $errno,
+                $errstr,
+                $errfile,
+                $errline
+            ));
+        });
+        
+        $this->scan(array("Pman"));
+        $this->scan(array("Hebe"));
         
-//        $this->scan($this->rootDir, 'Pman');
-        $this->scan($dir, $cls);
+        exit;
     }
     
-    function scan($dir, $cls
+    function scan($route = array()
     {
+        $dir = $this->rootDir . "/" . implode("/", $route);
         
+        echo "Looking for {$dir}\n";
         
-        foreach (scandir(implode('/', $dir)) as $d) {
+        foreach (scandir($dir) as $d) {
             
             if (!strlen($d) || $d[0] == '.') {
                 continue;
             }
             
             if (is_dir($d)) {
-                $nDir = array_merge($dir, array($d));
-                $this->scan(array_merge($dir, array($d)), array_merge($cls, array($d)));
-                return;
+                $this->scan(array_merge($route, array($d)));
+                continue;
             }
             
-            echo "{$d}\n";
+            if (!preg_match('/\.php$/', $d)) {
+                continue;
+            }
+            
+            if(empty($route)){
+                continue;
+            }
+            
+            try {
+                
+                require_once implode('/', $route) . "/" . $d;
+                
+            } catch (ErrorException $ex) {
+                echo $ex->getMessage() . "\n";
+            }
             
         }