<?php
namespace tool;
use sR\Adapter;
use sR\sR;
class WebChain
{
protected $initMk = true;
function __construct()
{
if(Adapter::isDebug()){
$this->projectCheckValid();
}
$routerFile = sR::WebRouterFile;
if(is_file($routerFile)){
require_once($routerFile);
}
}
function projectCheckValid(){
$msg = $this->getErrorMsg();
if(!$this->initMk){
new WebIniter(['msg'=>$msg]);
die();
}
}
function getErrorMsg(){
$msgQueue = [];
$routerDir = sR::WebRouterFile;
$conf = Adapter::getAppConfig();
$autoLoader = $conf->value('auto_router');
if(!is_file($routerDir) && !$autoLoader){
$msgQueue[] = '路由器未配置(router/web.php)';
$this->initMk = false;
}
if($autoLoader){
if(!is_dir(sR::HttpDir)){
$msgQueue[] = '项目未初始化!';
$this->initMk = false;
}
}
return $msgQueue;
}
}