@@ -12,8 +12,8 @@ |
||
| 12 | 12 | $this->init(); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function init($encoding = 'UTF-8') { |
|
| 16 | - $this->document = new \DOMDocument('1.0', $encoding); |
|
| 15 | + public function init($encoding='UTF-8') { |
|
| 16 | + $this->document=new \DOMDocument('1.0', $encoding); |
|
| 17 | 17 | $this->preserveWhiteSpace(false); |
| 18 | 18 | return $this; |
| 19 | 19 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @var array |
| 17 | 17 | */ |
| 18 | - protected $loadedConfigurations = []; |
|
| 18 | + protected $loadedConfigurations=[]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * 应用的根目录. |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | $this->initConfig(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - private function initEnv(){ |
|
| 34 | - try{ |
|
| 35 | - $dotEnv = new Dotenv($this->basePath); |
|
| 33 | + private function initEnv() { |
|
| 34 | + try { |
|
| 35 | + $dotEnv=new Dotenv($this->basePath); |
|
| 36 | 36 | $dotEnv->load(); |
| 37 | 37 | } |
| 38 | - catch (\Dotenv\Exception\InvalidPathException $e){ |
|
| 38 | + catch (\Dotenv\Exception\InvalidPathException $e) { |
|
| 39 | 39 | die("环境配置文件`.env`没有被找到."); |
| 40 | 40 | } |
| 41 | 41 | date_default_timezone_set(env('APP_TIMEZONE', 'Asia/Shanghai')); |
| 42 | 42 | define('IS_CLI', $this->runningInConsole()); |
| 43 | - define('IS_DEBUG',env('DEBUG',false)); |
|
| 43 | + define('IS_DEBUG', env('DEBUG', false)); |
|
| 44 | 44 | if (IS_DEBUG) { |
| 45 | 45 | error_reporting(E_ALL); |
| 46 | 46 | @ini_set('display_errors', 'On'); |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | private function initContainer() { |
| 70 | 70 | static::setInstance($this); |
| 71 | - $this->instance('app',$this); |
|
| 72 | - $this->instance('config',new Config()); |
|
| 73 | - $this->instance('request',new Request($this->config)); |
|
| 74 | - $this->instance('route',new Route($this->request)); |
|
| 75 | - $this->bind('pinyin','\puck\helpers\PinYin'); |
|
| 76 | - $this->bind('curl','\puck\helpers\Curl'); |
|
| 71 | + $this->instance('app', $this); |
|
| 72 | + $this->instance('config', new Config()); |
|
| 73 | + $this->instance('request', new Request($this->config)); |
|
| 74 | + $this->instance('route', new Route($this->request)); |
|
| 75 | + $this->bind('pinyin', '\puck\helpers\PinYin'); |
|
| 76 | + $this->bind('curl', '\puck\helpers\Curl'); |
|
| 77 | 77 | $this->bind('dom', '\puck\helpers\Dom'); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | //标记为已加载 |
| 96 | - $this->loadedConfigurations[$name] = true; |
|
| 97 | - $path = $this->getConfigurationPath($name); |
|
| 96 | + $this->loadedConfigurations[$name]=true; |
|
| 97 | + $path=$this->getConfigurationPath($name); |
|
| 98 | 98 | if ($path) { |
| 99 | 99 | $this->make('config')->set($name, require $path); |
| 100 | 100 | } |
@@ -110,21 +110,21 @@ discard block |
||
| 110 | 110 | * @param string|null $name |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public function getConfigurationPath($name = null) |
|
| 113 | + public function getConfigurationPath($name=null) |
|
| 114 | 114 | { |
| 115 | - if (! $name) { |
|
| 116 | - $appConfigDir = $this->basePath('configs').'/'; |
|
| 115 | + if (!$name) { |
|
| 116 | + $appConfigDir=$this->basePath('configs').'/'; |
|
| 117 | 117 | |
| 118 | 118 | if (file_exists($appConfigDir)) { |
| 119 | 119 | return $appConfigDir; |
| 120 | - } elseif (file_exists($path = __DIR__.'/configs/')) { |
|
| 120 | + } elseif (file_exists($path=__DIR__.'/configs/')) { |
|
| 121 | 121 | return $path; |
| 122 | 122 | } |
| 123 | 123 | } else { |
| 124 | - $appConfigPath = $this->basePath('configs').'/'.$name.'.php'; |
|
| 124 | + $appConfigPath=$this->basePath('configs').'/'.$name.'.php'; |
|
| 125 | 125 | if (file_exists($appConfigPath)) { |
| 126 | 126 | return $appConfigPath; |
| 127 | - } elseif (file_exists($path = __DIR__.'/configs/'.$name.'.php')) { |
|
| 127 | + } elseif (file_exists($path=__DIR__.'/configs/'.$name.'.php')) { |
|
| 128 | 128 | return $path; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | * @param string|null $path |
| 137 | 137 | * @return string |
| 138 | 138 | */ |
| 139 | - public function basePath($path = null) { |
|
| 139 | + public function basePath($path=null) { |
|
| 140 | 140 | if (isset($this->basePath)) { |
| 141 | - return $this->basePath . ($path ? '/' . $path : $path); |
|
| 141 | + return $this->basePath.($path ? '/'.$path : $path); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ($this->runningInConsole()) { |
| 145 | - $this->basePath = getcwd(); |
|
| 145 | + $this->basePath=getcwd(); |
|
| 146 | 146 | } else { |
| 147 | - $this->basePath = realpath(getcwd() . '/../'); |
|
| 147 | + $this->basePath=realpath(getcwd().'/../'); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | return $this->basePath($path); |