|
1
|
|
|
<?php |
|
2
|
|
|
// +---------------------------------------------------------------------- |
|
3
|
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ] |
|
4
|
|
|
// +---------------------------------------------------------------------- |
|
5
|
|
|
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved. |
|
6
|
|
|
// +---------------------------------------------------------------------- |
|
7
|
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) |
|
8
|
|
|
// +---------------------------------------------------------------------- |
|
9
|
|
|
// | Author: liu21st <[email protected]> |
|
10
|
|
|
// +---------------------------------------------------------------------- |
|
11
|
|
|
declare (strict_types = 1); |
|
12
|
|
|
|
|
13
|
|
|
namespace think\facade; |
|
14
|
|
|
|
|
15
|
|
|
use think\Facade; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @see \think\App |
|
19
|
|
|
* @package think\facade |
|
20
|
|
|
* @mixin \think\App |
|
21
|
|
|
* @method static \think\Service|null register(\think\Service|string $service, bool $force = false) 注册服务 |
|
22
|
|
|
* @method static mixed bootService(\think\Service $service) 执行服务 |
|
23
|
|
|
* @method static \think\Service|null getService(string|\think\Service $service) 获取服务 |
|
24
|
|
|
* @method static \think\App debug(bool $debug = true) 开启应用调试模式 |
|
25
|
|
|
* @method static bool isDebug() 是否为调试模式 |
|
26
|
|
|
* @method static \think\App setNamespace(string $namespace) 设置应用命名空间 |
|
27
|
|
|
* @method static string getNamespace() 获取应用类库命名空间 |
|
28
|
|
|
* @method static string version() 获取框架版本 |
|
29
|
|
|
* @method static string getRootPath() 获取应用根目录 |
|
30
|
|
|
* @method static string getBasePath() 获取应用基础目录 |
|
31
|
|
|
* @method static string getAppPath() 获取当前应用目录 |
|
32
|
|
|
* @method static mixed setAppPath(string $path) 设置应用目录 |
|
33
|
|
|
* @method static string getRuntimePath() 获取应用运行时目录 |
|
34
|
|
|
* @method static void setRuntimePath(string $path) 设置runtime目录 |
|
35
|
|
|
* @method static string getThinkPath() 获取核心框架目录 |
|
36
|
|
|
* @method static string getConfigPath() 获取应用配置目录 |
|
37
|
|
|
* @method static string getConfigExt() 获取配置后缀 |
|
38
|
|
|
* @method static float getBeginTime() 获取应用开启时间 |
|
39
|
|
|
* @method static integer getBeginMem() 获取应用初始内存占用 |
|
40
|
|
|
* @method static \think\App initialize() 初始化应用 |
|
41
|
|
|
* @method static bool initialized() 是否初始化过 |
|
42
|
|
|
* @method static void loadLangPack(string $langset) 加载语言包 |
|
43
|
|
|
* @method static void boot() 引导应用 |
|
44
|
|
|
* @method static void loadEvent(array $event) 注册应用事件 |
|
45
|
|
|
* @method static string parseClass(string $layer, string $name) 解析应用类的类名 |
|
46
|
|
|
* @method static bool runningInConsole() 是否运行在命令行下 |
|
47
|
|
|
*/ |
|
48
|
|
|
class App extends Facade |
|
49
|
|
|
{ |
|
50
|
|
|
/** |
|
51
|
|
|
* 获取当前Facade对应类名(或者已经绑定的容器对象标识) |
|
52
|
|
|
* @access protected |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
|
|
protected static function getFacadeClass() |
|
56
|
|
|
{ |
|
57
|
|
|
return 'app'; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: