Procházet zdrojové kódy

workerman autoloader

walkor před 10 roky
rodič
revize
c1d0b67888

+ 2 - 0
GatewayWorker/BusinessWorker.php

@@ -22,6 +22,8 @@ class BusinessWorker extends Worker
     {
         $this->onWorkerStart = array($this, 'onWorkerStart');
         parent::__construct($socket_name, $context_option);
+        $backrace = debug_backtrace();
+        $this->_appInitPath = dirname($backrace[0]['file']);
     }
     
     protected function onWorkerStart()

+ 3 - 0
GatewayWorker/Gateway.php

@@ -37,6 +37,9 @@ class Gateway extends Worker
         $this->onClose = array($this, 'onClientClose');
         $this->onWorkerStop = array($this, 'onWorkerStop');
         parent::__construct($socket_name, $context_option);
+        
+        $backrace = debug_backtrace();
+        $this->_appInitPath = dirname($backrace[0]['file']);
     }
     
     public function onClientMessage($connection, $data)

+ 1 - 1
Workerman/Autoloader.php

@@ -14,7 +14,7 @@ class Autoloader
 
     public static function setRootPath($root_path)
     {
-        self::$_appInitPath = $root_path;
+          self::$_appInitPath = $root_path;
     }
 
     public static function loadByNamespace($name)