rabin před 2 dny
rodič
revize
e4e605b7d4

+ 113 - 90
src/Dever/Import.php → src/Dever/App.php

@@ -1,91 +1,114 @@
-<?php namespace Dever;
-use Dever;
-class Import
-{
-    public $class;
-    public $path;
-    public function __construct($class, $app, $path)
-    {
-        $this->class = false;
-        $this->path = $path;
-        $project = Project::load($app);
-        if (strpos($project['path'], 'http') === 0) {
-            $this->class = $project;
-        } else {
-            $this->class = Library::load($class, $app, $path);
-        }
-    }
-    public function __call($method, $param)
-    {
-        return $this->loadDevelop($method, $param);
-    }
-    public function loadDevelop($method, $param)
-    {
-        if (is_array($this->class)) {
-            return $this->loadServer();
-        }
-        if ($this->path == 'api') {
-            if (method_exists($this->class, $method . '_secure')) {
-                $key = false;
-                $token = $method . '_token';
-                if (method_exists($this->class, $token)) {
-                    $key = $this->class->{$token}();
-                }
-                \Dever\Helper\Secure::check($param, 300, $key);
-            }
-            if ($param && is_array($param) && !isset($param[0])) {
-                $reflectionMethod = new \ReflectionMethod($this->class, $method);
-                $data = $reflectionMethod->getParameters();
-                $result = [];
-                foreach ($data as $k => $v) {
-                    $name = $v->name;
-                    if (isset($param[$name])) {
-                        $result[] = $param[$name];
-                    }
-                }
-                $param = $result;
-            } else {
-                if (!is_array($param)) {
-                    $param = [$param];
-                }
-            }
-        }
-        return $this->loadDevelopCommit($method, $param);
-    }
-    private function loadDevelopCommit($method, $param)
-    {
-        if (method_exists($this->class, $method . '_cmd') && DEVER_PROTO != 'cmd') {
-            Dever::error('route error');
-        }
-        if (method_exists($this->class, $method . '_commit') && Dever::$commit) {
-            $db = end(\Dever\Store\Pdo::$instance);
-            if (!$db) {
-                $db = Dever::store();
-            }
-            try {
-                Dever::$commit = false;
-                $db->begin();
-                $data = $this->loadDevelopMethod($method, $param);
-                $db->commit();
-                return $data;
-            } catch (\Exception $e) {
-                $db->rollback();
-                $data = $e->getTrace();
-                Debug::trace($data);
-                throw new \Exception(json_encode($data));
-            }
-        } else {
-            return $this->loadDevelopMethod($method, $param);
-        }
-    }
-    private function loadServer()
-    {
-        return 'error';
-    }
-    private function loadDevelopMethod($method, $param)
-    {
-        $data = $this->class->$method(...$param);
-        Debug::lib($this->class, $method);
-        return $data;
-    }
+<?php namespace Dever;
+use Dever;
+class App
+{
+    public $app = '';
+    public $name = '';
+    public $class = null;
+    public function __initialize($class)
+    {
+        if ($class && empty($this->class)) {
+            if (strpos($class, '/')) {
+                [$this->app, $this->name] = explode('/', $class, 2);
+                $class = strtr($class, '/', '\\');
+            } else {
+                [$this->app, $this->name] = explode('\\', $class, 2);
+                $this->name = strtr($this->name, '\\', '/');
+            }
+            $project = Dever::project($this->app);
+            if ($project) {
+                if (strpos($project['path'], 'http') === 0) {
+                    $this->class = $project;
+                } else {
+                    if (strpos($this->name, 'Manage') === 0) {
+                        $path = 'manage';
+                        Dever::load(\Manage\Lib\Auth::class);
+                        $this->name = str_replace('Manage/', '', $this->name);
+                    } else {
+                        $path = 'app';
+                    }
+                    require_once $project['path'] . $path . DIRECTORY_SEPARATOR . $this->name . '.php';
+                    
+                    $this->class = Dever::get($class);
+                }
+            }
+        }
+        return $this;
+    }
+    public function __call($method, $param)
+    {
+        return $this->loadDevelop($method, $param);
+    }
+    public function loadDevelop($method, $param)
+    {
+        if (is_array($this->class)) {
+            return $this->loadServer();
+        }
+        if (!method_exists($this->class, $method)) {
+            Dever::error($method . ' error');
+        }
+        if (strpos($this->name, 'Api') === 0) {
+            if (method_exists($this->class, $method . '_secure')) {
+                $key = false;
+                $token = $method . '_token';
+                if (method_exists($this->class, $token)) {
+                    $key = $this->class->{$token}();
+                }
+                \Dever\Helper\Secure::check($param, 300, $key);
+            }
+            if ($param && is_array($param) && !isset($param[0])) {
+                $reflectionMethod = new \ReflectionMethod($this->class, $method);
+                $data = $reflectionMethod->getParameters();
+                $result = [];
+                foreach ($data as $k => $v) {
+                    $name = $v->name;
+                    if (isset($param[$name])) {
+                        $result[] = $param[$name];
+                    }
+                }
+                $param = $result;
+            } else {
+                if (!is_array($param)) {
+                    $param = [$param];
+                }
+            }
+        }
+        return $this->loadDevelopCommit($method, $param);
+    }
+    private function loadDevelopCommit($method, $param)
+    {
+        if (method_exists($this->class, $method . '_cmd') && DEVER_PROTO != 'cmd') {
+            Dever::error('route error');
+        }
+        if (method_exists($this->class, $method . '_commit') && Dever::getCommit()) {
+            $db = end(\Dever\Store\Pdo::$instance);
+            if (!$db) {
+                $db = Dever::store();
+            }
+            try {
+                Dever::setCommit();
+                $db->begin();
+                $data = $this->loadDevelopMethod($method, $param);
+                $db->commit();
+                return $data;
+            } catch (\Exception $e) {
+                $db->rollback();
+                $data = $e->getTrace();
+                Dever::get(Debug::class)->trace($data);
+                throw new \Exception(json_encode($data));
+            }
+        } else {
+            return $this->loadDevelopMethod($method, $param);
+        }
+    }
+    private function loadServer()
+    {
+        return 'error';
+    }
+    private function loadDevelopMethod($method, $param)
+    {
+        $data = $this->class->$method(...$param);
+        Dever::get(Debug::class)->lib($this->class, $method);
+        return $data;
+    }
 }

+ 9 - 9
src/Dever/Config.php

@@ -1,24 +1,24 @@
 <?php namespace Dever;
 class Config
 {
-    protected static $data = [];
-    public static function get($key = 'setting', $data = false)
+    protected $data = [];
+    public function get($key = 'setting', $data = false)
     {
-        if (empty(self::$data[$key])) {
+        if (empty($this->data[$key])) {
             $path = DEVER_PROJECT_PATH . 'config' . DIRECTORY_SEPARATOR;
-            $env = self::env($path);
+            $env = $this->env($path);
             $file = $path . $key . '.php';
-            self::$data[$key] = [];
+            $this->data[$key] = [];
             if (is_file($file)) {
-                self::$data[$key] = include($file);
+                $this->data[$key] = include($file);
             }
         }
         if ($data) {
-            self::$data[$key] = array_merge(self::$data[$key], $data);
+            $this->data[$key] = array_merge($this->data[$key], $data);
         }
-        return self::$data[$key];
+        return $this->data[$key];
     }
-    protected static function env($path)
+    protected function env($path)
     {
         if (empty($_SERVER['DEVER_ENV_NAME'])) {
             $_SERVER['DEVER_ENV_NAME'] = 'localhost';

+ 70 - 69
src/Dever/Debug.php

@@ -2,23 +2,23 @@
 use Dever;
 class Debug
 {
-    public static $shell;
-    private static $data;
-    private static $trace;
-    private static $time;
-    private static $memory;
-    private static $start;
-    public static function init()
+    public $shell;
+    private $data;
+    private $trace;
+    private $time;
+    private $memory;
+    private $start;
+    public function init()
     {
         ini_set('display_errors', true);
-        self::$start = microtime();
-        set_error_handler([__CLASS__, 'error_handler'], E_ERROR | E_NOTICE | E_STRICT);
-        set_exception_handler([__CLASS__, 'exception_handler']);
-        self::$shell = Dever::shell(Config::get('setting')['shell']);
+        $this->start = microtime();
+        set_error_handler([$this, 'error_handler'], E_ERROR | E_NOTICE | E_STRICT);
+        set_exception_handler([$this, 'exception_handler']);
+        $this->shell = Dever::shell(Dever::config('setting')['shell']);
     }
-    public static function error_handler($no, $str, $file, $line)
+    public function error_handler($no, $str, $file, $line)
     {
-        self::$shell = true;
+        $this->shell = true;
         $data['msg'] = $str;
         $data['file'] = $file . ':' . $line;
         $content = file_get_contents($file);
@@ -35,43 +35,44 @@ class Debug
             $code .= "\n";
         }
         $code .= '</code>';
-        self::add($code, false);
-        self::out($data, false);
+        $this->add($code, false);
+        $this->out($data, false);
     }
-    public static function exception_handler($exception)
+    public function exception_handler($exception)
     {
-        self::error_handler($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
+        $this->error_handler($exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine());
     }
-    public static function add($data, $type = 'log')
+    public function add($data, $type = 'log')
     {
-        if (self::$shell) {
+        if ($this->shell) {
             $msg = $data;
             if ($type) {
                 $msg = is_array($msg) ? $msg : ['msg' => $msg];
-                $msg = array_merge($msg, self::env());
+                $msg = array_merge($msg, $this->env());
             }
-            self::data($type, Output::format($msg));
+            $this->data($type, Dever::get(Output::class)->format($msg));
         }
         return $data;
     }
-    public static function out($data, $type = 'out')
+    public function out($data, $type = 'out')
     {
-        if (self::$shell) {
-            self::add($data, $type);
-            self::total();
-            echo self::html();die;
+        if ($this->shell) {
+            $this->add($data, $type);
+            $this->total();
+            Dever::endRequest();
+            echo $this->html();die;
         }
     }
-    public static function total()
+    public function total()
     {
-        self::data('include', Output::format(self::load()));
-        $msg = array('time' => self::time(), 'memory' => self::memory());
-        self::data('total', Output::format($msg));
+        $this->data('include', Dever::get(Output::class)->format($this->load()));
+        $msg = array('time' => $this->time(), 'memory' => $this->memory());
+        $this->data('total', Dever::get(Output::class)->format($msg));
         return $msg;
     }
-    public static function lib($class, $method)
+    public function lib($class, $method)
     {
-        if (self::$shell) {
+        if ($this->shell) {
             $class = new \ReflectionClass($class);
             $trace['file'] = $class->getFileName();
             $trace['line'] = $class->getStartLine();
@@ -85,56 +86,56 @@ class Debug
                 }
             }
             $key = $trace['file'] . ':' . $trace['line'];
-            self::$trace[$key] = $trace;
+            $this->trace[$key] = $trace;
         }
     }
-    public static function trace()
+    public function trace()
     {
         $debug = debug_backtrace();
         $trace = '';
         if ($debug) {
             foreach($debug as $k => $v) {
-                if (self::check($v)) {
+                if ($this->check($v)) {
                     $trace = $v['file'] . ':' . $v['line'];
-                    self::$trace[$trace] = $v;
+                    $this->trace[$trace] = $v;
                     break;
                 }
             }
         }
-        if (!$trace && self::$trace) {
-            $trace = array_keys(self::$trace);
+        if (!$trace && $this->trace) {
+            $trace = array_keys($this->trace);
             $trace = $trace[0];
         }
         return $trace;
     }
-    public static function getTrace()
+    public function getTrace()
     {
-        if (self::$trace) {
-            return array_reverse(array_values(self::$trace));
+        if ($this->trace) {
+            return array_reverse(array_values($this->trace));
         }
         return [];
     }
-    private static function env()
+    private function env()
     {
-        $trace = self::trace();
+        $trace = $this->trace();
         return array
         (
-            'time' => 'current:' . self::time(2) . ' total:' . self::time(),
-            'memory' => 'current:' . self::memory(2) . ' total:' . self::memory(),
+            'time' => 'current:' . $this->time(2) . ' total:' . $this->time(),
+            'memory' => 'current:' . $this->memory(2) . ' total:' . $this->memory(),
             'trace' => $trace
         );
     }
-    private static function data($method, $msg)
+    private function data($method, $msg)
     {
         if (!$method) {
             $method = 'error';
         }
-        self::$data[$method][] = $msg;
+        $this->data[$method][] = $msg;
     }
-    private static function check($value)
+    private function check($value)
     {
         if (isset($value['file']) && strpos($value['file'], DEVER_APP_PATH) !== false) {
-            $config = ['lib', 'api', 'table'];
+            $config = ['app', 'manage', 'table'];
             foreach ($config as $k => $v) {
                 if (strpos($value['file'], DEVER_APP_PATH . $v) !== false) {
                     return true;
@@ -143,40 +144,40 @@ class Debug
         }
         return false;
     }
-    private static function time($state = 1)
+    private function time($state = 1)
     {
-        $start = self::startTime($state);
-        $end = self::endTime();
+        $start = $this->startTime($state);
+        $end = $this->endTime();
         return '[' . ($end - $start) . 'S]';
     }
-    private static function endTime()
+    private function endTime()
     {
-        self::$time = microtime();
-        return self::createTime(self::$time);
+        $this->time = microtime();
+        return $this->createTime($this->time);
     }
-    private static function startTime($state = 1)
+    private function startTime($state = 1)
     {
-        $start = self::$start;
-        if ($state == 2 && self::$time) {
-            $start = self::$time;
+        $start = $this->start;
+        if ($state == 2 && $this->time) {
+            $start = $this->time;
         }
-        return self::createTime($start);
+        return $this->createTime($start);
     }
-    private static function createTime($time)
+    private function createTime($time)
     {
         list($a, $b) = explode(' ', $time);
         return ((float) $a + (float) $b);
     }
-    private static function memory($state = 1)
+    private function memory($state = 1)
     {
         $memory = memory_get_usage();
-        if ($state == 2 && self::$memory) {
-            $memory = $memory - self::$memory;
+        if ($state == 2 && $this->memory) {
+            $memory = $memory - $this->memory;
         }
-        self::$memory = $memory;
+        $this->memory = $memory;
         return '[' . ($memory / 1024) . 'KB]';
     }
-    private static function load()
+    private function load()
     {
         $files = get_included_files();
         $result = [];
@@ -188,12 +189,12 @@ class Debug
         }
         return $result;
     }
-    private static function html($show = '')
+    private function html($show = '')
     {
         $html = '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/atom-one-dark.min.css">
 <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script><div>';
-        if (self::$data) {
-            foreach (self::$data as $k => $v) {
+        if ($this->data) {
+            foreach ($this->data as $k => $v) {
                 $html .= $k;
                 $html .= '<table style="width:100%;">';
                 foreach ($v as $i => $j) {

+ 8 - 7
src/Dever/File.php

@@ -1,18 +1,19 @@
 <?php namespace Dever;
+use Dever;
 class File
 {
-    public static function id($id, $path)
+    public function id($id, $path)
     {
         $id = abs(intval($id));
         $sid = sprintf("%09d", $id);
         $dir1 = substr($sid, 0, 3);
         $dir2 = substr($sid, 3, 2);
         $dir3 = substr($sid, 5, 2);
-        return self::get($path . DIRECTORY_SEPARATOR . $dir1 . DIRECTORY_SEPARATOR . $dir2 . DIRECTORY_SEPARATOR . $dir3 . DIRECTORY_SEPARATOR . $id . '.jpg');
+        return $this->get($path . DIRECTORY_SEPARATOR . $dir1 . DIRECTORY_SEPARATOR . $dir2 . DIRECTORY_SEPARATOR . $dir3 . DIRECTORY_SEPARATOR . $id . '.jpg');
     }
-    public static function get($file, $path = '')
+    public function get($file, $path = '')
     {
-        $file = self::data() . DEVER_PROJECT . DIRECTORY_SEPARATOR . $file;
+        $file = $this->data() . DEVER_PROJECT . DIRECTORY_SEPARATOR . $file;
         $path = dirname($file);
         if (!is_dir($path)) {
             mkdir($path, 0777, true);
@@ -21,10 +22,10 @@ class File
         }
         return $file;
     }
-    public static function data()
+    public function data()
     {
-        if (isset(Config::get('setting')['data'])) {
-            return Config::get('setting')['data'];
+        if (isset(Dever::config('setting')['data'])) {
+            return Dever::config('setting')['data'];
         }
         return DEVER_PROJECT_PATH . 'data' . DIRECTORY_SEPARATOR;
     }

+ 3 - 2
src/Dever/Helper/Lang.php

@@ -1,12 +1,13 @@
 <?php namespace Dever\Helper;
+use Dever;
 class Lang
 {
     private static $data = [];
     public static function get($key = 'host', $param = [])
     {
-        $name = 'lang/' . Config::get('setting')['lang'];
+        $name = 'lang/' . Dever::config('setting')['lang'];
         if (empty(self::$data[$name])) {
-            self::$data[$name] = Config::get($name);
+            self::$data[$name] = Dever::get(Config::class)->get($name);
         }
         if (isset(self::$data[$name][$key])) {
             self::$data[$name][$key] = self::replace(self::$data[$name][$key], $param);

+ 0 - 54
src/Dever/Library.php

@@ -1,54 +0,0 @@
-<?php namespace Dever;
-class Library
-{
-    protected static $class;
-    protected static $load;
-    public static function autoload($class)
-    {
-        if (empty(self::$load[$class])) {
-            $class = explode('\\', $class);
-            if (isset($class[3])) {
-                self::require(lcfirst($class[0]), lcfirst($class[1]) . DIRECTORY_SEPARATOR . $class[2] . DIRECTORY_SEPARATOR . $class[3]);
-            } elseif (isset($class[2])) {
-                self::require(lcfirst($class[0]), lcfirst($class[1]) . DIRECTORY_SEPARATOR . $class[2]);
-            }
-        }
-    }
-    public static function require($app, $file)
-    {
-        $project = Project::load($app);
-        if ($project) {
-            require_once $project['path'] . $file . '.php';
-        }
-    }
-    public static function apply($file, $app, $path)
-    {
-        if (strpos($file, '/')) {
-            $class = str_replace(' ', '/', ucwords(str_replace('/', ' ', $file)));
-            $file = $path . DIRECTORY_SEPARATOR . $class;
-            $class = str_replace('/', '\\', $class);
-        } else {
-            $class = ucfirst($file);
-            $file = $path . DIRECTORY_SEPARATOR . $file;
-        }
-        $class = ucfirst($app) . '\\' . ucfirst($path) . '\\' . $class;
-        if (empty(self::$load[$class])) {
-            self::$load[$class] = true;
-            self::require($app, $file);
-        }
-        return $class;
-    }
-    public static function load($class, $app, $path)
-    {
-        if (strstr($class, 'manage/')) {
-            $auth = new \Manage\Lib\Auth();
-            $class = str_replace('manage/', 'lib/', $class);
-            $path = 'manage';
-        }
-        $class = self::apply(ucfirst($class), $app, $path);
-        if (empty(self::$class[$class])) {
-            self::$class[$class] = new $class();
-        }
-        return self::$class[$class];
-    }
-}

+ 22 - 22
src/Dever/Log.php

@@ -2,24 +2,24 @@
 use Dever;
 class Log
 {
-    public static function add($log, $type = 1)
+    public function add($log, $type = 1)
     {
-        if (!$config = Config::get('setting')['log']) {
+        if (!$config = Dever::config('setting')['log']) {
             return;
         }
         $config['level'] = $type;
-        return self::push(self::filter($log), $config);
+        return $this->push($this->filter($log), $config);
     }
-    private static function push($log, $config)
+    private function push($log, $config)
     {
         $method = 'push_' . $config['type'];
-        return self::$method($log, $config);
+        return $this->$method($log, $config);
     }
-    private static function push_http($log, $config)
+    private function push_http($log, $config)
     {
         return false;
     }
-    private static function push_udp($log, $config)
+    private function push_udp($log, $config)
     {
         $handle = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
         if ($handle) {
@@ -27,7 +27,7 @@ class Log
             socket_close($handle);
         }
     }
-    private static function push_syslog($log, $config)
+    private function push_syslog($log, $config)
     {
         if ($config['level'] == 1) {
             $level = LOG_DEBUG;
@@ -46,12 +46,12 @@ class Log
         syslog($level, $log);
         closelog();
     }
-    private static function push_file($log, $config)
+    private function push_file($log, $config)
     {
         $day = date('Y/m/d');
         $time = date('H:i:s');
         $log = $day . ' ' . $time . ' ' . DEVER_PROJECT . ' ' . DEVER_APP_NAME . ' ' . $log . "\r\n";
-        $file = self::file($config['level'], $day, substr($time, 0, 2));
+        $file = $this->file($config['level'], $day, substr($time, 0, 2));
         $size = 5242880;
         if (isset($config['size'])) {
             $size = $config['size'];
@@ -71,31 +71,31 @@ class Log
         }
         return $state;
     }
-    public static function get($day, $type = 1)
+    public function get($day, $type = 1)
     {
-        if (is_array(Config::get('setting')['log'])) {
-            $method = Config::get('setting')['log']['type'];
+        if (is_array(Dever::config('setting')['log'])) {
+            $method = Dever::config('setting')['log']['type'];
         } else {
             $method = 'syslog';
         }
         $method = 'get_' . $method;
-        return self::$method($day, $type);
+        return $this->$method($day, $type);
     }
-    private static function get_http($day, $type)
+    private function get_http($day, $type)
     {
         return false;
     }
-    private static function get_udp($day, $type)
+    private function get_udp($day, $type)
     {
         return false;
     }
-    private static function get_syslog($day, $type)
+    private function get_syslog($day, $type)
     {
         return false;
     }
-    private static function get_file($day, $type)
+    private function get_file($day, $type)
     {
-        $file = self::file($type, $day);
+        $file = $this->file($type, $day);
         $content = '';
         $path = dirname($file);
         if (is_dir($path)) {
@@ -111,14 +111,14 @@ class Log
         }
         return [];    
     }
-    public static function filter($string)
+    public function filter($string)
     {
         if (is_array($string)) {
             $string = Dever::json_encode($string);
         }
         return $string;
     }
-    private static function file($level, $day, $hour = '')
+    private function file($level, $day, $hour = '')
     {
         if ($level == 1) {
             $file = 'debug';
@@ -132,6 +132,6 @@ class Log
         if ($hour) {
             $file .= '_' . $hour;
         }
-        return File::get('logs/' . $day . DIRECTORY_SEPARATOR . $file);
+        return Dever::get(File::class)->get('logs/' . $day . DIRECTORY_SEPARATOR . $file);
     }
 }

+ 15 - 12
src/Dever/Model.php

@@ -6,9 +6,10 @@ class Model
     protected $store;
     protected $partition = false;
     public $config = [];
-    public function __construct($table, $app, $store, $partition, $path)
+    public function __initialize($table, $store, $partition, $path)
     {
-        $project = Project::load($app);
+        [$app, $table] = explode('/', $table, 2);
+        $project = Dever::project($app);
         if ($table) {
             $base = $project['path'] . $path . DIRECTORY_SEPARATOR . $table . '.php';
             if (is_file($base)) {
@@ -34,8 +35,9 @@ class Model
         }
         $this->store = Dever::store($store, $this->partition);
         if (isset($file)) {
-            $this->init($path, $store, $file);
+            $this->write($path, $store, $file);
         }
+        return $this;
     }
     public function partition($partition)
     {
@@ -64,11 +66,11 @@ class Model
     }
     private function lang()
     {
-        if (isset($this->config['lang']) && isset($this->config['struct']) && $pack = Config::get('setting')['lang_pack']) {
+        if (isset($this->config['lang']) && isset($this->config['struct']) && $pack = Dever::config('setting')['lang_pack']) {
             foreach ($this->config['lang'] as $lang) {
                 if (isset($this->config['struct'][$lang])) {
                     foreach ($pack as $key => $value) {
-                        if (Config::get('setting')['lang'] != $key) {
+                        if (Dever::config('setting')['lang'] != $key) {
                             $this->config['struct'][$key . '_' . $lang] = $this->config['struct'][$lang];
                         }
                     }
@@ -76,7 +78,7 @@ class Model
             }
         }
     }
-    private function init($path, $store, $file)
+    private function write($path, $store, $file)
     {
         $path .= DIRECTORY_SEPARATOR . $store;
         $data['index'] = $data['struct'] = 0;
@@ -102,7 +104,7 @@ class Model
                 $data['field'] = 0;
             }
         }
-        $file = File::get($path . DIRECTORY_SEPARATOR . $file);
+        $file = Dever::get(File::class)->get($path . DIRECTORY_SEPARATOR . $file);
         if (is_file($file)) {
             $data = include $file;
         }
@@ -150,14 +152,14 @@ class Model
             }
         }
         if (isset($set['num'])) {
-            $set['limit'] = Paginator::init($set['num'], $set['page'] ?? 1, function()use($param){return $this->count($param);});
+            $set['limit'] = Dever::get(Paginator::class)->init($set['num'], $set['page'] ?? 1, function()use($param){return $this->count($param);});
         }
         if ($version && isset($this->config['type']) && $this->config['type'] == 'myisam') {
             $version = false;
         }
         $result = $this->store->select($this->config['table'], $param, $set, $this->config['struct'], $version);
         if (isset($set['num']) && empty($set['page'])) {
-            Paginator::status(empty($result));
+            Dever::get(Paginator::class)->status(empty($result));
         }
         return $result;
     }
@@ -277,7 +279,7 @@ class Model
                 $temp = explode('limit', $sql);
                 $sql = $temp[0];
             }
-            $limit = Paginator::init($page['num'], $page['page'] ?? 1, function()use($sql, $bind){return $this->queryCount($sql, $bind);});
+            $limit = self::get(Paginator::class)->init($page['num'], $page['page'] ?? 1, function()use($sql, $bind){return $this->queryCount($sql, $bind);});
             if (is_array($limit)) {
                 $limit = implode(',', $limit);
             }
@@ -286,7 +288,7 @@ class Model
         $result = $this->store->query($sql, $bind);
         if (isset($page['num']) && empty($page['page'])) {
             $result = $result->fetchAll();
-            Paginator::status(empty($result));
+            self::get(Paginator::class)->status(empty($result));
         }
         return $result;
     }
@@ -340,7 +342,8 @@ class Model
                         $option = Dever::db($option)->select([], ['col' => $col]);
                     }
                 }
-            } elseif (is_array($option) && !isset($option[0])) {
+            }
+            if (is_array($option) && !isset($option[0])) {
                 $temp = $option;
                 $option = [];
                 $col = explode(',', $col);

+ 30 - 28
src/Dever/Output.php

@@ -2,38 +2,38 @@
 use Dever;
 class Output
 {
-    private static $format = 'json';
-    public static function success($data, $uuid = false, $code = 200)
+    private $format = 'json';
+    public function success($data, $uuid = false, $code = 200)
     {
         $result = [];
         $result['status'] = 1;
         $result['msg'] = 'success';
         $result['data'] = $data;
         $result['code'] = $code;
-        if ($page = Paginator::get()) {
+        if ($page = Dever::get(Paginator::class)->get()) {
             $result['page'] = $page;
         }
         if ($uuid) {
             $result['uuid'] = Dever::uuid();
         }
-        $result = self::setting($result);
-        self::handle($result);
+        $result = $this->setting($result);
+        $this->handle($result);
         return $data;
     }
-    public static function error($msg, $code = 500)
+    public function error($msg, $code = 500)
     {
         $result = [];
         $result['status'] = 2;
         $result['code'] = $code;
         $result['msg'] = $msg;
-        self::handle($result);
+        $this->handle($result);
         die;
     }
-    public static function out($result)
+    public function out($result)
     {
-        return self::handle($result);
+        return $this->handle($result);
     }
-    public static function format($data)
+    public function format($data)
     {
         if (is_array($data)) {
             $data = htmlspecialchars(json_encode($data, JSON_PRETTY_PRINT + JSON_UNESCAPED_SLASHES + JSON_UNESCAPED_UNICODE));
@@ -43,7 +43,7 @@ class Output
         $content .= "\n</pre>\n";
         return $content;
     }
-    public static function setting($result)
+    public function setting($result)
     {
         $setting = Dever::config('setting');
         if (isset($setting['output_app']) && $setting['output_app'] && !in_array(DEVER_APP_NAME, $setting['output_app'])) {
@@ -72,48 +72,50 @@ class Output
         }
         return $result;
     }
-    public static function handle(&$result)
+    public function handle(&$result)
     {
-        Debug::out($result);
-        self::json($result);
-        self::callback($result);
-        self::func($result);
-        if (self::$format == 'json') {
+        Dever::get(Debug::class)->out($result);
+        $this->json($result);
+        $this->callback($result);
+        $this->func($result);
+        if ($this->format == 'json') {
+            Dever::endRequest();
             header('Content-Type: application/json');
             header('Content-Length: ' . strlen($result));
             print_r($result);
         } else {
-            self::html($result);
+            Dever::endRequest();
+            $this->html($result);
         }
     }
-    private static function json(&$result)
+    private function json(&$result)
     {
-        if (self::$format == 'json' || Route::input('json') == 1) {
+        if ($this->format == 'json' || Dever::get(Route::class)->input('json') == 1) {
             if (!$result) {
                 $result = (object) $result;
             }
             $result = Dever::json_encode($result);
-            self::$format = 'json';
+            $this->format = 'json';
         } else {
-            self::$format = 'str';
+            $this->format = 'str';
         }
     }
-    private static function callback(&$result)
+    private function callback(&$result)
     {
-        if ($callback = Route::input('callback')) {
+        if ($callback = Dever::get(Route::class)->input('callback')) {
             $result = $callback . '(' . $result . ')';
         }
     }
-    private static function func(&$result)
+    private function func(&$result)
     {
-        if ($function = Route::input('function')) {
+        if ($function = Dever::get(Route::class)->input('function')) {
             $result = '<script>parent.' . $function . '(' . $result . ')' . '</script>';
         }
     }
-    public static function html($msg)
+    public function html($msg)
     {
         $html = '' . $msg['msg'];
-        $host = Route::url('');
+        $host = Dever::get(Route::class)->url('');
         $name = '404';
         if ($msg['code'] > 1) {
             $name = $msg['code'];

+ 62 - 61
src/Dever/Paginator.php

@@ -1,56 +1,57 @@
 <?php namespace Dever;
+use Dever;
 class Paginator
 {
-    protected static $status = false;
-    protected static $num;
-    protected static $rows;
-    protected static $current;
-    protected static $html = '';
-    protected static $link;
-    public static function init($num, $page, $rows)
+    protected $status = false;
+    protected $num;
+    protected $rows;
+    protected $current;
+    protected $html = '';
+    protected $link;
+    public function init($num, $page, $rows)
     {
-        self::$num = $num;
-        self::$rows = $rows;
-        self::$current = Route::input('pg', '', '', $page);
-        $offset = self::$num * (self::$current-1);
+        $this->num = $num;
+        $this->rows = $rows;
+        $this->current = Dever::input('pg', '', '', $page);
+        $offset = $this->num * ($this->current-1);
         if ($offset >= 10000) {
-            return [$offset, self::$num];
+            return [$offset, $this->num];
         }
-        return $offset . ',' . self::$num;
+        return $offset . ',' . $this->num;
     }
-    public static function status($status)
+    public function status($status)
     {
-        self::$status = !$status;
+        $this->status = !$status;
     }
-    public static function get($template = '', $maxpage = 10, $link = '')
+    public function get($template = '', $maxpage = 10, $link = '')
     {
-        if (self::$rows) {
+        if ($this->rows) {
             if ($template == 'total') {
-                return (self::$rows)();
+                return ($this->rows)();
             }
-            $page['num'] = self::$num;
-            $page['status'] = self::$status;
-            $page['current'] = self::$current;
+            $page['num'] = $this->num;
+            $page['status'] = $this->status;
+            $page['current'] = $this->current;
             if ($template) {
-                $page['rows'] = self::$rows = (self::$rows)();
-                $page['next'] = $page['total'] = ceil(self::$rows / self::$num);
-                if (self::$current < $page['total']) {
-                    $page['next'] = self::$current+1;
+                $page['rows'] = $this->rows = ($this->rows)();
+                $page['next'] = $page['total'] = ceil($this->rows / $this->num);
+                if ($this->current < $page['total']) {
+                    $page['next'] = $this->current+1;
                 } else {
-                    self::$current = $page['total'];
+                    $this->current = $page['total'];
                 }
-                $page['prev'] = self::$current-1;
+                $page['prev'] = $this->current-1;
                 if ($page['prev'] < 1) {
                     $page['prev'] = 1;
                 }
-                self::handle($page, $maxpage);
-                $page['html'] = self::html($page, $template, $maxpage, $link);
+                $this->handle($page, $maxpage);
+                $page['html'] = $this->html($page, $template, $maxpage, $link);
             }
             return $page;
         }
         return false;
     }
-    protected static function handle(&$page, $maxpage)
+    protected function handle(&$page, $maxpage)
     {
         if ($page['total'] <= $maxpage) {
             $page['start'] = 1;
@@ -79,67 +80,67 @@ class Paginator
             }
         }
     }
-    public static function link($page)
+    public function link($page)
     {
-        if (is_string(self::$link)) {
-            return Route::url(self::$link, ['pg' => $page]);
+        if (is_string($this->link)) {
+            return Dever::url($this->link, ['pg' => $page]);
         }
-        return (self::$link)($page);
+        return ($this->link)($page);
     }
-    protected static function html($page, $template, $maxpage, $link)
+    protected function html($page, $template, $maxpage, $link)
     {
         $file = DEVER_PROJECT_PATH . 'page/' . $template . '.php';
         if (is_file($file)) {
             $html = include $file;
-            self::$link = $link;
-            if (!self::$link) {
-                self::$link = Route::url(false);
-                if (strpos(self::$link, 'pg=') !== false) {
-                    self::$link = preg_replace('/[?|&]pg=(\d+)/i', '', self::$link);
+            $this->link = $link;
+            if (!$this->link) {
+                $this->link = Dever::url(false);
+                if (strpos($this->link, 'pg=') !== false) {
+                    $this->link = preg_replace('/[?|&]pg=(\d+)/i', '', $this->link);
                 }
             }
             if (is_array($html)) {
-                self::template($html, $page);
+                $this->template($html, $page);
             } else {
-                self::$html = $html;
+                $this->html = $html;
             }
         }
-        return self::$html;
+        return $this->html;
     }
-    protected static function template($html, $page)
+    protected function template($html, $page)
     {
-        self::$html = '';
+        $this->html = '';
         if ($page['current'] > 1 && isset($html['start'])) {
-            self::$html .= self::create($html['child'], $html['start'][1], 1, $html['start'][0], $html['page'][2]);
+            $this->html .= $this->create($html['child'], $html['start'][1], 1, $html['start'][0], $html['page'][2]);
         }
         if (isset($html['prev'])) {
-            self::$html .= self::create($html['child'], $html['prev'][1], $page['prev'], $html['prev'][0], $html['page'][2]);
+            $this->html .= $this->create($html['child'], $html['prev'][1], $page['prev'], $html['prev'][0], $html['page'][2]);
         }
         $i = $page['start'];
         for ($i; $i <= $page['end']; $i++) {
-            self::$html .= self::create($html['child'], self::getClass($i, $html['page'], $page), $i, $i, $html['page'][2]);
+            $this->html .= $this->create($html['child'], $this->getClass($i, $html['page'], $page), $i, $i, $html['page'][2]);
         }
         if (isset($html['next'])) {
-            self::$html .= self::create($html['child'], $html['next'][1], $page['next'], $html['next'][0], $html['page'][2]);
+            $this->html .= $this->create($html['child'], $html['next'][1], $page['next'], $html['next'][0], $html['page'][2]);
         }
         if (isset($html['end']) && $page['current'] < $page['total']) {
-            self::$html .= self::create($html['child'], $html['end'][1], $page['total'], $html['end'][0], $html['page'][2]);
+            $this->html .= $this->create($html['child'], $html['end'][1], $page['total'], $html['end'][0], $html['page'][2]);
         }
         if (isset($html['jump'])) {
-            $click = 'onclick="var link=\'' . self::link('dever_page') . '\';location.href=link.replace(\'dever_page\', document.getElementById(\'dever_page\').value)"';
-            self::$html .= str_replace('{click}', $click, $html['jump']);
+            $click = 'onclick="var link=\'' . $this->link('dever_page') . '\';location.href=link.replace(\'dever_page\', document.getElementById(\'dever_page\').value)"';
+            $this->html .= str_replace($click, $html['jump'], '{click}');
         }
-        self::$html = self::tag($html['parent'], self::$html);
+        $this->html = $this->tag($html['parent'], $this->html);
     }
-    protected static function create($child, $class, $num, $name, $type = '')
+    protected function create($child, $class, $num, $name, $type = '')
     {
         if ($type == 'parent') {
             $child[1] = 'class="' . $class . '"';
             $class = '';
         }
-        return self::tag($child, self::getContent($child, $class, $num, $name));
+        return $this->tag($child, $this->getContent($child, $class, $num, $name));
     }
-    protected static function tag($tag, $content)
+    protected function tag($tag, $content)
     {
         if (!$tag) {
             return $content;
@@ -152,21 +153,21 @@ class Paginator
         }
         return '<' . $tag . ' ' . $attr . '>' . $content . '</' . $tag . '>';
     }
-    protected static function getContent($child, $class, $num, $name)
+    protected function getContent($child, $class, $num, $name)
     {
         if ($child && $child[0] == 'a') {
-            $child[1] = self::attr($class, self::link($num));
+            $child[1] = $this->attr($class, $this->link($num));
             $content = $name;
         } else {
-            $content = self::tag(array('a', self::attr($class, self::link($num))), $name);
+            $content = $this->tag(array('a', $this->attr($class, $this->link($num))), $name);
         }
         return $content;
     }
-    protected static function attr($class, $href)
+    protected function attr($class, $href)
     {
         return ' class="' . $class . '" href="' . $href . '" ';
     }
-    protected static function getClass($index, $html, $page)
+    protected function getClass($index, $html, $page)
     {
         $class = $html[0];
         if ($index == $page['current']) {

+ 55 - 48
src/Dever/Project.php

@@ -1,101 +1,108 @@
 <?php namespace Dever;
+use Dever;
 class Project
 {
-    protected static $content = [];
-    public static function init()
+    protected $content = [];
+    public function init()
     {
-        $file = File::get('app.php');
-        if (!self::$content) {
+        $file = Dever::get(File::class)->get('app.php');
+        if (!$this->content) {
             if (is_file($file)) {
                 require $file;
-                self::$content = $project;
+                $this->content = $project;
             }
-            if (isset(Config::get('setting')['app'])) {
-                self::$content = array_merge(self::$content, Config::get('setting')['app']);
+            if (isset(Dever::config('setting')['app'])) {
+                $this->content = array_merge($this->content, Dever::config('setting')['app']);
             }
         }
         return $file;
     }
-    public static function register()
+    public function register()
     {
-        $file = self::init();
-        if (empty(self::$content[DEVER_APP_NAME])) {
+        $file = $this->init();
+        if (empty($this->content[DEVER_APP_NAME])) {
             $host = DEVER_APP_HOST;
-            $path = explode('_', DEVER_APP_NAME);
-            if (strpos($host, '/src/' . DEVER_APP_NAME)) {
-                $host = explode('/src/' . DEVER_APP_NAME, $host)[0] . '/';
-            } elseif (strpos($host, '/app/' . DEVER_APP_NAME)) {
-                $host = explode('/app/' . DEVER_APP_NAME, $host)[0] . '/';
-            }elseif (strpos($host, '/package/' . DEVER_APP_NAME)) {
-                $host = explode('/package/' . DEVER_APP_NAME, $host)[0] . '/';
+            $name = strtolower(DEVER_APP_NAME);
+            if (strpos($host, '/src/' . $name)) {
+                $host = explode('/src/' . $name, $host)[0] . '/';
+            } elseif (strpos($host, '/package/' . $name)) {
+                $host = explode('/package/' . $name, $host)[0] . '/';
             }
-            self::write($host, 'package');
-            //self::write($host, 'package');self::write($host, 'src');self::write($host, 'app');
-            self::$content[DEVER_APP_NAME]['url'] = DEVER_APP_HOST;
-            if (empty(self::$content[DEVER_APP_NAME]['path'])) {
-                self::$content[DEVER_APP_NAME]['path'] = DEVER_APP_PATH;
+            $this->write($host, 'package');$this->write($host, 'src');
+            //$this->write($host, 'package');$this->write($host, 'src');$this->write($host, 'app');
+            $this->content[DEVER_APP_NAME]['url'] = DEVER_APP_HOST;
+            if (empty($this->content[DEVER_APP_NAME]['path'])) {
+                $this->content[DEVER_APP_NAME]['path'] = DEVER_APP_PATH;
             }
-            if (isset(self::$content['manage'])) {
-                $manage = self::$content['manage'];
-                unset(self::$content['manage']);
-                self::$content = array_merge(['manage' => $manage], self::$content);
+            if (isset($this->content['manage'])) {
+                $manage = $this->content['manage'];
+                unset($this->content['manage']);
+                $this->content = array_merge(['manage' => $manage], $this->content);
             }
-            self::content($file);
-            if (isset(self::$content['manage'])) {
-                \Dever::load('menu', 'manage')->init();
+            $this->content($file);
+            if (isset($this->content['manage'])) {
+                Dever::load(\Manage\Lib\Menu::class)->init();
             }
         }
-        if (empty(self::$content[DEVER_APP_NAME]['lang'])) {
-            self::$content[DEVER_APP_NAME]['lang'] = DEVER_APP_LANG;
-            self::content($file);
+        if (empty($this->content[DEVER_APP_NAME]['lang'])) {
+            $this->content[DEVER_APP_NAME]['lang'] = DEVER_APP_LANG;
+            $this->content($file);
         }
 
     }
-    public static function write($host, $name)
+    public function write($host, $name)
     {
         $dir = DEVER_PROJECT_PATH . $name . '/';
         if (is_dir($dir)) {
             $data = scandir($dir);
             foreach ($data as $v) {
-                if (empty(self::$content[$v]) && is_dir($dir . '/' . $v) && $v !== '.' && $v !== '..') {
+                $n = ucfirst($v);
+                if (empty($this->content[$n]) && is_dir($dir . '/' . $v) && $v !== '.' && $v !== '..') {
                     $p = $v;
                     $k = $name . '/' . $v . '/';
                     if ($v == 'manage') {
                         $p = 'manage/api';
                     }
                     if (is_file($dir . $p . '/index.php')) {
-                        self::$content[$v] = [];
+                        $this->content[$n] = [];
                         if (strstr($name, 'package')) {
-                            self::$content[$v]['path'] = DEVER_PATH . $k;
+                            $this->content[$n]['path'] = DEVER_PATH . $k;
                             if ($v == 'manage') {
                                 $k .= 'api/';
                             }
-                            self::$content[$v]['setup'] = DEVER_PROJECT_PATH . $k;
+                            $this->content[$n]['setup'] = DEVER_PROJECT_PATH . $k;
                         } else {
-                            self::$content[$v]['path'] = DEVER_PROJECT_PATH . $k;
+                            $this->content[$n]['path'] = DEVER_PROJECT_PATH . $k;
                         }
-                        self::$content[$v]['url'] = $host . $k;
+                        $this->content[$n]['url'] = $host . $k;
                     } else {
-                        self::write($host, $name . '/' . $v);
+                        $this->write($host, $name . '/' . $v);
                     }
                 }
             }
         }
     }
-    public static function content($file)
+    public function content($file)
     {
-        file_put_contents($file, '<?php $project = ' . var_export(self::$content, true) . ';');
+        file_put_contents($file, '<?php $project = ' . var_export($this->content, true) . ';');
     }
-    public static function read()
+    public function read()
     {
-        return self::$content;
+        return $this->content;
     }
-    public static function load($app)
+    public function load($app)
     {
-        if (isset(self::$content[$app])) {
-            return self::$content[$app];
+        if (ctype_lower($app)) {
+            if (strpos($app, '_')) {
+                $app = str_replace(' ', '', ucwords(str_replace('_', ' ', $app)));
+            } else {
+                $app = ucfirst($app);
+            }
+        }
+        if (isset($this->content[$app])) {
+            return $this->content[$app];
         }
-        Output::error('app not exists:' . $app);
+        Dever::error('app not exists:' . $app);
         return false;
     }
 }

+ 54 - 46
src/Dever/Route.php

@@ -1,33 +1,34 @@
 <?php namespace Dever;
+use Dever;
 class Route
 {
-    public static $data = [];
-    protected static $type = '?l=';
-    public static function input($key = false, $condition = '', $lang = '', $value = '')
+    public $data = [];
+    protected $type = '?l=';
+    public function input($key = false, $condition = '', $lang = '', $value = '')
     {
         if (!$key) {
-            return self::$data;
+            return $this->data;
         }
         if ($condition == 'set') {
-            return self::$data[$key] = $lang;
+            return $this->data[$key] = $lang;
         }
         if (is_array($key)) {
             foreach ($key as $v) {
-                $v = self::input($v, $condition, $lang, $value);
+                $v = $this->input($v, $condition, $lang, $value);
                 if ($v) {
                     return $v;
                 }
             }
         }
-        if (is_string($key) && isset(self::$data[$key]) && self::$data[$key] && self::$data[$key] != 'false') {
-            $value = self::$data[$key];
+        if (is_string($key) && isset($this->data[$key]) && $this->data[$key] && $this->data[$key] != 'false') {
+            $value = $this->data[$key];
         }
         if ($condition) {
             if (!$lang) {
                 $lang = $key;
             }
             if (!$value && $value !== 0) {
-                Output::error($lang . '不能为空');
+                Dever::get(Output::class)->error($lang . '不能为空');
             }
             $state = true;
             if (strpos($condition, '/') === 0) {
@@ -36,12 +37,12 @@ class Route
                 $state = $condition($value);
             }
             if (!$state) {
-                Output::error($lang . '验证无效');
+                Dever::get(Output::class)->error($lang . '验证无效');
             }
         }
         return $value;
     }
-    public static function url($uri = false, $param = [], $auth = false, $rewrite = '')
+    public function url($uri = false, $param = [], $auth = false, $rewrite = '')
     {
         if ($uri == false) {
             if (DEVER_APP_HOST) {
@@ -58,20 +59,24 @@ class Route
             return $uri;
         }
         if (strpos($uri, '/')) {
-            $temp = explode('/', $uri);
+            $temp = explode('/', $uri, 2);
             $app = $temp[0];
-            $uri = str_replace($app . '/', '', $uri);
+            $uri = $temp[1];
+            if (strpos($uri, 'Api') === 0) {
+                $uri = str_replace('Api/', '', $uri);
+                $uri = lcfirst($uri);
+            }
         } else {
             $app = DEVER_APP_NAME;
         }
-        $project = Project::load($app);
+        $project = Dever::project($app);
         if (!$uri) {
             return $project['url'];
         }
         if ($auth) {
             $param['authorization'] = \Dever\Helper\Str::encode(\Dever\Helper\Env::header('authorization'));
         }
-        if ($route = Config::get('setting')['route']) {
+        if ($route = Dever::config('setting')['route']) {
             if ($search = array_search($uri, $route)) {
                 $uri = $search;
             }
@@ -101,12 +106,12 @@ class Route
         if ($rewrite) {
             return str_replace($rewrite, '', $project['url']) . $uri;
         }
-        if (self::$type == '?l=' && strpos($uri, '?')) {
+        if ($this->type == '?l=' && strpos($uri, '?')) {
             $uri = str_replace('?', '&', $uri);
         }
-        return $project['url'] . self::$type . $uri;
+        return $project['url'] . $this->type . $uri;
     }
-    public static function host()
+    public function host()
     {
         $temp = explode('/', DEVER_PROJECT_PATH);
         $name = '/' . $temp[count($temp)-2] . '/';
@@ -118,24 +123,24 @@ class Route
         }
         return $host;
     }
-    public static function get()
+    public function get()
     {
-        if (!self::command()) {
-            self::api();
+        if (!$this->command()) {
+            $this->api();
         }
-        self::match();
-        self::filter(self::$data);
-        if (isset(self::$data['uuid']) && isset(Config::get('setting')['redis']) && !\Dever\Helper\Redis::lock(self::$data['uuid'], 1, 60)) {
-            Output::error('route repeat');
+        $this->match();
+        $this->filter($this->data);
+        if (isset($this->data['uuid']) && isset(Dever::config('setting')['redis']) && !\Dever\Helper\Redis::lock($this->data['uuid'], 1, 60)) {
+            Dever::get(Output::class)->error('route repeat');
         }
-        return self::$data;
+        return $this->data;
     }
-    protected static function command()
+    protected function command()
     {
         if (isset($_SERVER['argc'])) {
             global $argv;
             if (isset($argv[1]) && $argv[1]) {
-                self::$data = \Dever::json_decode($argv[1]);
+                $this->data = \Dever::json_decode($argv[1]);
             }
             define('DEVER_PROTO', 'cmd');
             define('DEVER_APP_HOST', '');
@@ -143,22 +148,22 @@ class Route
         }
         return false;
     }
-    protected static function api()
+    protected function api()
     {
-        self::$data = $_REQUEST;
+        $this->data = $_REQUEST;
         if (isset($_FILES) && $_FILES) {
-            self::$data = array_merge(self::$data, $_FILES);
+            $this->data = array_merge($this->data, $_FILES);
         }
-        $pathinfo = self::pathinfo();
+        $pathinfo = $this->pathinfo();
         if ($pathinfo) {
-            self::$data['l'] = trim($pathinfo, '/');
+            $this->data['l'] = trim($pathinfo, '/');
         } else {
-            self::$type = '?l=';
+            $this->type = '?l=';
         }
         define('DEVER_PROTO', ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http');
         define('DEVER_APP_HOST', DEVER_PROTO . '://' . $_SERVER['HTTP_HOST'] . ($_SERVER['SCRIPT_NAME'] ? substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], DEVER_ENTRY)) : DIRECTORY_SEPARATOR));
     }
-    protected static function pathinfo()
+    protected function pathinfo()
     {
         $pathinfo = '';
         if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO']) {
@@ -168,18 +173,21 @@ class Route
         }
         return $pathinfo;
     }
-    public static function match()
+    public function match()
     {
-        if (!isset(self::$data['l'])) {
-            self::$data['l'] = '';
+        if (!isset($this->data['l'])) {
+            $this->data['l'] = '';
         }
-        if ($route = Config::get('setting')['route']) {
-            $value = self::$data['l'];
+        if ($route = Dever::config('setting')['route']) {
+            $value = $this->data['l'];
             if (isset($route[$value])) {
-                self::$data['l'] = $route[$value];
+                $this->data['l'] = $route[$value];
             } else {
                 foreach ($route as $k => $v) {
-                    $k = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $k));
+                    $k = strtr($k, [
+                        ':any' => '.+',
+                        ':num' => '[0-9]+',
+                    ]);
                     if (preg_match('#^' . $k . '$#', $value)) {
                         if (strpos($v, '$') !== false && strpos($k, '(') !== false) {
                             $v = preg_replace('#^' . $k . '$#', $v, $value);
@@ -188,20 +196,20 @@ class Route
                             $temp = explode('?', $v);
                             $v = $temp[0];
                             parse_str($temp[1], $data);
-                            self::$data = array_merge($data, self::$data);
+                            $this->data = array_merge($data, $this->data);
                         }
-                        self::$data['l'] = $v;
+                        $this->data['l'] = $v;
                     }
                 }
             }
         }
     }
-    protected static function filter(&$data)
+    protected function filter(&$data)
     {
         if ($data) {
             foreach ($data as $k => $v) {
                 if (is_array($v)) {
-                    self::filter($v);
+                    $this->filter($v);
                 } else {
                     if ($data[$k] == 'undefined') {
                         $data[$k] = '';

+ 2 - 1
src/Dever/Session.php

@@ -1,4 +1,5 @@
 <?php namespace Dever;
+use Dever;
 use Dever\Helper\Secure;
 class Session
 {
@@ -12,7 +13,7 @@ class Session
         if (!self::$start) {
             @header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
             @ini_set('session.gc_maxlifetime', 86400);
-            if (isset(Config::get('setting')['session']) && $session = Config::get('setting')['session']) {
+            if (isset(Dever::config('setting')['session']) && $session = Dever::config('setting')['session']) {
                 ;
                 if (isset($session['host'])) {
                     $link = 'tcp://'.$session['host'].':'.$session['port'] . '?persistent=1&weight=1&timeout=1&retry_interval=15';

+ 36 - 35
src/Dever/Sql.php

@@ -1,40 +1,41 @@
 <?php namespace Dever;
+use Dever;
 class Sql
 {
-    public static function desc($table)
+    public function desc($table)
     {
         return 'DESC ' . $table;
     }
-    public static function truncate($table)
+    public function truncate($table)
     {
         return 'TRUNCATE TABLE `' . $table . '`';
     }
-    public static function optimize($table)
+    public function optimize($table)
     {
         return 'OPTIMIZE TABLE `' . $table . '`';
     }
-    public static function analyze($table)
+    public function analyze($table)
     {
         return 'ANALYZE TABLE `' . $table . '`';
     }
-    public static function explain($sql)
+    public function explain($sql)
     {
         return 'EXPLAIN ' . $sql;
     }
-    public static function showIndex($table)
+    public function showIndex($table)
     {
         return 'SHOW INDEX FROM ' . $table;
     }
-    public static function create($config)
+    public function create($config)
     {
-        if (isset(Config::get('setting')['database']['create']) && !Config::get('setting')['database']['create']) {
+        if (isset(Dever::config('setting')['database']['create']) && !Dever::config('setting')['database']['create']) {
             return;
         }
         $sql = 'DROP TABLE IF EXISTS `' . $config['table'] . '`;CREATE TABLE IF NOT EXISTS `' . $config['table'] . '`(';
         $struct = array('id' => array('name' => 'ID', 'type' => 'int(11)'),'cdate' => array('name' => 'cdate', 'type' => 'int(11)'));
         $struct = array_merge($struct, $config['struct']);
         foreach ($struct as $k => $v) {
-            $sql .= self::createField($k, $v) . ',';
+            $sql .= $this->createField($k, $v) . ',';
         }
         $sql = rtrim($sql, ',') . ')';
         if (isset($config['auto'])) {
@@ -45,7 +46,7 @@ class Sql
         }
         return $sql . ' COMMENT="'.$config['name'].'"';
     }
-    public static function createField($name, $set)
+    public function createField($name, $set)
     {
         $field = '`' . $name . '` ' . strtoupper($set['type']);
         if ($name == 'id') {
@@ -64,7 +65,7 @@ class Sql
         }
         return $field;
     }
-    public static function alter($table, $struct, $data)
+    public function alter($table, $struct, $data)
     {
         $sql = [];
         $alter = 'ALTER TABLE `' . $table . '` ';
@@ -74,7 +75,7 @@ class Sql
                 $set = $struct[$field] ?? false;
                 if ($set) {
                     if ($set['type'] != $v['Type'] || (isset($set['default']) && $set['default'] != $v['Default'])) {
-                        $sql[] = $alter . ' CHANGE `' . $field . '` ' . self::createField($field, $set);
+                        $sql[] = $alter . ' CHANGE `' . $field . '` ' . $this->createField($field, $set);
                     } else {
                         unset($struct[$field]);
                     }
@@ -85,12 +86,12 @@ class Sql
         }
         if ($struct) {
             foreach ($struct as $k => $v) {
-                $sql[] = $alter . ' ADD ' . self::createField($k, $v);
+                $sql[] = $alter . ' ADD ' . $this->createField($k, $v);
             }
         }
         return implode(';', $sql);
     }
-    public static function index($table, $index, $del = [])
+    public function index($table, $index, $del = [])
     {
         $sql = [];
         $alter = 'ALTER TABLE `' . $table . '` ';
@@ -110,7 +111,7 @@ class Sql
         }
         return implode(';', $sql);
     }
-    public static function partition($table, $partition, $index)
+    public function partition($table, $partition, $index)
     {
         $state = true;
         foreach ($index as $k => $v) {
@@ -147,10 +148,10 @@ class Sql
             if ($state) {
                 return $alter . 'PARTITIONS ' . $partition['value'];
             }
-            return self::desc($table);
+            return $this->desc($table);
         }
     }
-    public static function select($table, $param, &$bind, $set = [], $field = [], $version = false, $type = '')
+    public function select($table, $param, &$bind, $set = [], $field = [], $version = false, $type = '')
     {
         $col = '*';
         $rule = '';
@@ -174,7 +175,7 @@ class Sql
         }
         if (isset($set['limit'])) {
             if (is_array($set['limit']) && !$type) {
-                $table .= ' inner join (select id from ' . $table . self::where($param, $bind, $field) . $rule . ' limit ' . $set['limit'][0].','.$set['limit'][1].') as t on '.$table.'.id=t.id';
+                $table .= ' inner join (select id from ' . $table . $this->where($param, $bind, $field) . $rule . ' limit ' . $set['limit'][0].','.$set['limit'][1].') as t on '.$table.'.id=t.id';
                 $rule = '';
                 $param = false;
             } else {
@@ -189,9 +190,9 @@ class Sql
         if ($version) {
             $rule .= ' FOR UPDATE';
         }
-        return 'SELECT ' . $col . ' FROM ' . $table . self::where($param, $bind, $field, $type) . $rule;
+        return 'SELECT ' . $col . ' FROM ' . $table . $this->where($param, $bind, $field, $type) . $rule;
     }
-    public static function where($param, &$bind, $field = [], $type = '')
+    public function where($param, &$bind, $field = [], $type = '')
     {
         if ($param) {
             $first = $second = '';
@@ -205,21 +206,21 @@ class Sql
                         $first_link = $second_link = '';
                         foreach ($v as $k1 => $v1) {
                             if (is_array($v1)) {
-                                self::field($second_link, $bind, $i, $k1, $v1[0], $v1[1], $field, $type);
+                                $this->field($second_link, $bind, $i, $k1, $v1[0], $v1[1], $field, $type);
                             } else {
-                                self::field($first_link, $bind, $i, $k1, '=', $v1, $field, $type);
+                                $this->field($first_link, $bind, $i, $k1, '=', $v1, $field, $type);
                             }
                         }
-                        $second .= ' ' . $k . ' (' . self::replace($first_link) . $second_link . ')';
+                        $second .= ' ' . $k . ' (' . $this->replace($first_link) . $second_link . ')';
                     } else {
                         if (is_array($v)) {
-                            self::field($second, $bind, $i, $k, $v[0], $v[1], $field, $type);
+                            $this->field($second, $bind, $i, $k, $v[0], $v[1], $field, $type);
                         } else {
-                            self::field($first, $bind, $i, $k, '=', $v, $field, $type);
+                            $this->field($first, $bind, $i, $k, '=', $v, $field, $type);
                         }
                     }
                 }
-                return ' WHERE ' . self::replace($first . $second);
+                return ' WHERE ' . $this->replace($first . $second);
             } elseif (is_numeric($param)) {
                 if ($type == 'Influxdb') {
                     return ' WHERE "id" = \'' . $param . '\'';
@@ -233,7 +234,7 @@ class Sql
             return '';
         }
     }
-    private static function field(&$sql, &$bind, &$num, $key, $symbol, $value, $field, $type)
+    private function field(&$sql, &$bind, &$num, $key, $symbol, $value, $field, $type)
     {
         $prefix = '';
         if (strstr($key, '.')) {
@@ -306,7 +307,7 @@ class Sql
         $state && $bind[$index] = $value;
         $num++;
     }
-    public static function insert($table, $data, &$bind, $field)
+    public function insert($table, $data, &$bind, $field)
     {
         $sql = 'INSERT INTO `' . $table . '` SET ';#IGNORE
         foreach ($data as $k => $v) {
@@ -321,7 +322,7 @@ class Sql
         }
         return rtrim($sql, ',');
     }
-    public static function update($table, $param, $data, &$bind, $field)
+    public function update($table, $param, $data, &$bind, $field)
     {
         $i = 0;
         $sql = 'UPDATE `' . $table . '` SET ';
@@ -345,13 +346,13 @@ class Sql
             $sql .= '`' . $k . '`=' . $a . ':' . $k . ',';
             $bind[':'.$k] = $v;
         }
-        return rtrim($sql, ',') . self::where($param, $bind, $field);
+        return rtrim($sql, ',') . $this->where($param, $bind, $field);
     }
-    public static function delete($table, $param, &$bind, $field)
+    public function delete($table, $param, &$bind, $field)
     {
-        return 'DELETE FROM `' . $table . '`' . self::where($param, $bind, $field);
+        return 'DELETE FROM `' . $table . '`' . $this->where($param, $bind, $field);
     }
-    public static function inserts($table, $param)
+    public function inserts($table, $param)
     {
         $num = $param['num'] ?? 1;
         $sql = 'INSERT INTO `' . $table . '` (' . $param['field'] . ') VALUES ';
@@ -363,11 +364,11 @@ class Sql
         $sql .= implode(',', $insert) . ',';
         return rtrim($sql, ',');
     }
-    public static function distance($lng, $lat)
+    public function distance($lng, $lat)
     {
         return 'round((st_distance(point(lng, lat), point('.$lng.', '.$lat.'))*111195)/1000, 2) as distance';
     }
-    private static function replace($string)
+    private function replace($string)
     {
         if (strpos($string, ' and ') === 0) {
             $string = substr($string, 5);

+ 2 - 4
src/Dever/Store/Base.php

@@ -1,7 +1,5 @@
 <?php namespace Dever\Store;
 use Dever;
-use Dever\Debug;
-use Dever\Output;
 class Base
 {
     protected $read;
@@ -34,11 +32,11 @@ class Base
     }
     protected function error($msg)
     {
-        Output::error(Dever::json_encode($msg));
+        Dever::out()->error(Dever::json_encode($msg));
     }
     protected function log($msg)
     {
-        Debug::add($msg, $this->type);
+        Dever::debug($msg, $this->type);
     }
     public function bsql(&$sql, $bind)
     {

+ 3 - 4
src/Dever/Store/Influxdb.php

@@ -1,7 +1,6 @@
 <?php namespace Dever\Store;
 use Dever;
 use Dever\Debug;
-use Dever\Output;
 use Dever\Sql;
 #https://docs.influxdata.com/influxdb/v2/api-guide/api_intro/
 class Influxdb extends Base
@@ -33,7 +32,7 @@ class Influxdb extends Base
         //echo $curl;die;
         */
         $result = Dever::curl($host, $param, $type, $json, $header)->result();
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->log(['param' => $param, 'result' => $result]);
         }
         return $result;
@@ -47,7 +46,7 @@ class Influxdb extends Base
     public function load($table, $param, $set, $field, $lock)
     {
         $bind = [];
-        $sql = Sql::select($table, $param, $bind, $set, $field, $lock, $this->type);
+        $sql = Dever::get(Sql::class)->select($table, $param, $bind, $set, $field, $lock, $this->type);
         $data = $this->query($sql);
         $data = Dever::json_decode($data);
         if (isset($data['results'][0]['series'][0]['values'])) {
@@ -131,7 +130,7 @@ class Influxdb extends Base
         if ($tags) {
             $param .= ',' . implode(',', $tags);
         } else {
-            Dever::error('influxdb tags not null');
+            Dever::out()->error('influxdb tags not null');
         }
         if ($fields) {
             $param .= ' ' . implode(',', $fields);

+ 7 - 7
src/Dever/Store/Mongo.php

@@ -1,6 +1,6 @@
 <?php namespace Dever\Store;
+use Dever;
 use Dever\Debug;
-use Dever\Output;
 use MongoDB\Driver\Manager;
 use MongoDB\Driver\Command;
 use MongoDB\Driver\BulkWrite;
@@ -21,7 +21,7 @@ class Mongo extends Base
                 $setting['timeout'] = 1000;
             }
             $handle = new Manager('mongodb://' . $setting['host'] . ':' . $setting['port'], ['username' => $setting['user'], 'password' => $setting['pwd'], 'connectTimeoutMS' => $setting['timeout']]);
-            Debug::add('mongodb ' . $setting['host'] . ' connected', $setting['type']);
+            Dever::debug('mongodb ' . $setting['host'] . ' connected', $setting['type']);
             return $handle;
         } catch (\PDOException $e) {
             echo $e->getMessage();die;
@@ -162,7 +162,7 @@ class Mongo extends Base
             $query = new Query($param, $options);
             $result = $this->read->executeQuery($this->db . '.' . $table, $query);
         }
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'option' => $options, 'result' => $result]);
         }
         return $result;
@@ -194,7 +194,7 @@ class Mongo extends Base
         if (isset($data[0]) && $data[0]->count) {
             $result = $data[0]->count;
         }
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'result' => $result]);
         }
         return $result;
@@ -228,7 +228,7 @@ class Mongo extends Base
         $id = (array) $id;
         $id = $id['oid'];
         $result = $this->update->executeBulkWrite($this->db . '.' . $table, $bulk);
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->log(['table' => $this->db . '.' . $table, 'insert' => $insert, 'result' => $id]);
         }
         if ($result->getInsertedCount() >= 1) {
@@ -258,7 +258,7 @@ class Mongo extends Base
         $bulk->update($param, $update, ['multi' => true, 'upsert' => false]);
         $result = $this->update->executeBulkWrite($this->db . '.' . $table, $bulk);
         $result = $result->getModifiedCount();
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'update' => $update, 'result' => $result]);
         }
         return $result;
@@ -270,7 +270,7 @@ class Mongo extends Base
         $bulk->delete($param);
         $result = $this->update->executeBulkWrite($this->db . '.' . $table, $bulk);
         $result = $result->getDeletedCount();
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->log(['table' => $this->db . '.' . $table, 'param' => $param, 'result' => $result]);
         }
         return $result;

+ 21 - 19
src/Dever/Store/Pdo.php

@@ -1,11 +1,13 @@
 <?php namespace Dever\Store;
+use Dever;
 use Dever\Debug;
-use Dever\Output;
 use Dever\Sql;
 class Pdo extends Base
 {
+    protected $tool;
     protected function connect($setting)
     {
+        $this->tool = Dever::get(Sql::class);
         $this->type = $setting['type'];
         $handle = false;
         if (strpos($setting['host'], ':') !== false) {
@@ -33,14 +35,14 @@ class Pdo extends Base
             $handle->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
             //$handle->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
             //handle->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
-            Debug::add('db ' . $setting['host'] . ' connected', $setting['type']);
+            Dever::debug('db ' . $setting['host'] . ' connected', $setting['type']);
             return $handle;
         } catch (\PDOException $e) {
             if (strstr($e->getMessage(), 'Unknown database')) {
                 $this->create($setting);
                 return $this->connect($setting);
             } else {
-                Output::error($e->getMessage());
+                Dever::out()->error($e->getMessage());
             }
         }
     }
@@ -67,27 +69,27 @@ class Pdo extends Base
     public function struct($config, $state = 0)
     {
         if ($state) {
-            $sql = Sql::alter($config['table'], $config['struct'], $this->query(Sql::desc($config['table'])));
+            $sql = $this->tool->alter($config['table'], $config['struct'], $this->query($this->tool->desc($config['table'])));
             if ($sql) {
                 $this->query($sql);
             }
         } else {
-            $this->query(Sql::create($config));
+            $this->query($this->tool->create($config));
         }
         if (isset($config['default']) && $config['default']) {
             $count = $this->count($config['table'], [], $config['struct']);
             if (!$count) {
-                $this->query(Sql::inserts($config['table'], $config['default']));
+                $this->query($this->tool->inserts($config['table'], $config['default']));
             }
         }
     }
     public function index($config, $state = 0)
     {
-        $this->query(Sql::index($config['table'], $config['index'], $this->query(Sql::showIndex($config['table']))));
+        $this->query($this->tool->index($config['table'], $config['index'], $this->query($this->tool->showIndex($config['table']))));
     }
     public function partition($config, $partition)
     {
-        $this->query(Sql::partition($config['table'], $partition, $this->query(Sql::showIndex($config['table']))));
+        $this->query($this->tool->partition($config['table'], $partition, $this->query($this->tool->showIndex($config['table']))));
     }
     public function query($sql, $bind = [], $method = 'read')
     {
@@ -105,7 +107,7 @@ class Pdo extends Base
         } catch (\PDOException $exception) {
             $this->error(array('sql' => $sql, 'msg' => $exception->getMessage()));
         }
-        if (Debug::$shell) {
+        if (Dever::get(Debug::class)->shell) {
             $this->bsql($sql, $bind);
             $this->log(array('sql' => $sql, 'count' => $handle->rowCount()));
         }
@@ -114,13 +116,13 @@ class Pdo extends Base
     public function load($table, $param, $set, $field, $version)
     {
         $bind = [];
-        $sql = Sql::select($table, $param, $bind, $set, $field, $version);
+        $sql = $this->tool->select($table, $param, $bind, $set, $field, $version);
         return $this->query($sql, $bind);
     }
     public function sql($table, $param, $set, $field, $version)
     {
         $bind = '';
-        return Sql::select($table, $param, $bind, $set, $field, $version);
+        return $this->tool->select($table, $param, $bind, $set, $field, $version);
     }
     public function select($table, $param, $set, $field, $version)
     {
@@ -137,31 +139,31 @@ class Pdo extends Base
     public function explain($table, $param, $field)
     {
         $bind = [];
-        $sql = sql::explain(Sql::select($table, $param, $bind, array('col'=>'count(*)'), $field, false));
+        $sql = $this->tool->explain($this->tool->select($table, $param, $bind, array('col'=>'count(*)'), $field, false));
         return $this->query($sql, $bind)->fetch();
     }
     public function insert($table, $data, $field)
     {
         $bind = [];
-        $sql = Sql::insert($table, $data, $bind, $field);
+        $sql = $this->tool->insert($table, $data, $bind, $field);
         $this->query($sql, $bind, 'update');
         return $this->update->lastInsertId();
     }
     public function update($table, $param, $data, $field)
     {
         $bind = [];
-        $sql = Sql::update($table, $param, $data, $bind, $field);
+        $sql = $this->tool->update($table, $param, $data, $bind, $field);
         return $this->query($sql, $bind, 'update')->rowCount();
     }
     public function delete($table, $param, $field)
     {
         $bind = [];
-        $sql = Sql::delete($table, $param, $bind, $field);
+        $sql = $this->tool->delete($table, $param, $bind, $field);
         return $this->query($sql, $bind, 'update')->rowCount();
     }
     public function optimize($table)
     {
-        $sql = Sql::optimize($table) . ';' . Sql::analyze($table);
+        $sql = $this->tool->optimize($table) . ';' . $this->tool->analyze($table);
         return $this->query($sql, [], 'update');
     }
     public function begin()
@@ -178,16 +180,16 @@ class Pdo extends Base
     }
     public function transaction($class, $param, $msg)
     {
-        if (\Dever::$commit) {
+        if (Dever::getCommit()) {
             try {
-                \Dever::$commit = false;
+                Dever::setCommit();
                 $this->begin();
                 $result = call_user_func_array($class, $param);
                 $this->commit();
                 return $result;
             } catch (\Exception $e) {
                 $this->rollback();
-                Output::error($msg);
+                Dever::out()->error($msg);
             }
         } else {
             return call_user_func_array($class, $param);

+ 13 - 12
src/Dever/View.php

@@ -1,42 +1,43 @@
 <?php namespace Dever;
+use Dever;
 class View
 {
-    public static function show($file, $data, $app = '', $path = 'assets')
+    public function show($file, $data, $app = '', $path = 'assets')
     {
         if (!$app) {
             $app = DEVER_APP_NAME;
         }
-        $project = Project::load($app);
-        $template = self::template();
+        $project = Dever::project($app);
+        $template = $this->template();
         $path = $path . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR;
         if (strstr($project['path'], 'package')) {
             $package_path = str_replace(DEVER_PATH, '', $project['path']);
             $package_host = DEVER_PROTO . '://' . $_SERVER['HTTP_HOST'] . '/dever2/' . $package_path . $path;
         }
         $host = $project['url'] . $path;
-        $compile = File::get('compile' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . $file . '.php');
+        $compile = Dever::get(File::class)->get('compile' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . $file . '.php');
         Debug::add($compile, 'template');
         if (Debug::$shell) {
             return $data;
         }
         $template = $project['path'] . $path . 'template' . DIRECTORY_SEPARATOR . $file . '.html';
         if (!is_file($template)) {
-            Output::error('file not exists');
+            Dever::get(Output::class)->error('file not exists');
         }
         $create = true;
         if (is_file($compile) && filemtime($compile) >= filemtime($template)) {
             $create = false;
         }
         if ($create) {
-            self::create($template, $compile);
+            $this->create($template, $compile);
         }
         include($compile);die;
     }
-    private static function template()
+    private function template()
     {
         $template = 'default';
-        if (isset(Config::get('setting')['template']['name']) && Config::get('setting')['template']['name']) {
-            $template = Config::get('setting')['template']['name'];
+        if (isset(Dever::config('setting')['template']['name']) && Dever::config('setting')['template']['name']) {
+            $template = Dever::config('setting')['template']['name'];
             if (strpos($template, ',')) {
                 $temp = explode(',', $template);
                 if (\Dever\Helper\Env::mobile()) {
@@ -48,11 +49,11 @@ class View
         }
         return $template;
     }
-    private static function create($template, $compile)
+    private function create($template, $compile)
     {
         $content = file_get_contents($template);
-        if (isset(Config::get('setting')['template']['replace'])) {
-            foreach (Config::get('setting')['template']['replace'] as $k => $v) {
+        if (isset(Dever::config('setting')['template']['replace'])) {
+            foreach (Dever::config('setting')['template']['replace'] as $k => $v) {
                 $content = str_replace($k, $v, $content);
             }
         }