指定Resource目录方式的改变

This commit is contained in:
TOP糯米 2019-06-03 11:01:27 +08:00
parent 3db0e05509
commit 5b1aab990c
2 changed files with 22 additions and 3 deletions

View File

@ -31,13 +31,30 @@ class Framework {
defined('DEBUG') || define('DEBUG', false); defined('DEBUG') || define('DEBUG', false);
self::setResourceDir();
require 'library/App.php'; require 'library/App.php';
App::start(self::$type, self::$defaultAddress); 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 * @param string $address
*/ */
public static function setDefaultAddress($address) { public static function setDefaultAddress($address) {
@ -46,7 +63,6 @@ class Framework {
/** /**
* 指定程序运行方式 * 指定程序运行方式
*
* @param int $type * @param int $type
*/ */
public static function setRunType($type) { public static function setRunType($type) {

View File

@ -1,4 +1,7 @@
<?php <?php
use \top\Framework;
// 是否开启DEBUG模式 // 是否开启DEBUG模式
define('DEBUG', true); define('DEBUG', true);
// APP目录 // APP目录
@ -8,4 +11,4 @@ define('FRAMEWORK_PATH', '../framework/');
// 加载框架 // 加载框架
require '../framework/Framework.php'; require '../framework/Framework.php';
\top\Framework::startApp(); Framework::startApp();