thinkphp5.1 获取根目录
thinkphp5.1 获取根目录
use think\facade\Env;
Env::get('root_path');
其他路径获取:
// /thinkphp/library/think/App.php // 设置路径环境变量 $this->env->set([ 'think_path' => $this->thinkPath, 'root_path' => $this->rootPath, 'app_path' => $this->appPath, 'config_path' => $this->configPath, 'route_path' => $this->routePath, 'runtime_path' => $this->runtimePath, 'extend_path' => $this->rootPath . 'extend' . DIRECTORY_SEPARATOR, 'vendor_path' => $this->rootPath . 'vendor' . DIRECTORY_SEPARATOR, ]);