From 5b1aab990c1a12ebd26d14536f5b0b17f3f164ac Mon Sep 17 00:00:00 2001 From: topnuomi <1130395124@qq.com> Date: Mon, 3 Jun 2019 11:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E5=AE=9AResource=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E7=9A=84=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/Framework.php | 20 ++++++++++++++++++-- public/index.php | 5 ++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/framework/Framework.php b/framework/Framework.php index 6d5c1c6..b087e08 100644 --- a/framework/Framework.php +++ b/framework/Framework.php @@ -31,13 +31,30 @@ class Framework { defined('DEBUG') || define('DEBUG', false); + self::setResourceDir(); + require 'library/App.php'; App::start(self::$type, self::$defaultAddress); } + /** + * 指定Resource目录 + * @param string $resourceDir + */ + public static function setResourceDir($resourceDir = '') { + if (!defined('RESOURCE')) { + if (!$resourceDir && isset($_SERVER['SCRIPT_NAME'])) { + $scriptName = $_SERVER['SCRIPT_NAME']; + $pos = strrpos($scriptName, '/'); + $root = substr($scriptName, 0, $pos + 1); + $resourceDir = $root . 'resource/'; + } + define('RESOURCE', $resourceDir); + } + } + /** * 指定默认访问位置 - * * @param string $address */ public static function setDefaultAddress($address) { @@ -46,7 +63,6 @@ class Framework { /** * 指定程序运行方式 - * * @param int $type */ public static function setRunType($type) { diff --git a/public/index.php b/public/index.php index 2db0111..e677d3f 100644 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,7 @@