php小白求助,完整项目如何在自己计算机中运行

在github上下载了一个php项目,在phpstudy中导了数据库和创建了网站,点击登录没有反应,看原贴说是要调conf和base中的连接信息有哪位大神知道应该如何改

conf中代码

<?php
return array(
    //数据库配置
    'db_host'   =>  "127.0.0.1",
    'db_user'   =>  "123456",
    'db_pwd'    =>  "123456",
    'db_name'   =>  "bookmanger",
    'db_port'   =>  "3309",
    'charset'   =>  "utf8",

    //默认路由配置
    'default_plantform'   => "Common",
    'default_controller'  => "Login",
    'default_action'      => "index"
);

base.class中代码

<?php
abstract class Base{

    public static function Run(){
        self::pageInit();
        self::dirInit();
        self::autoLoad();
        self::readConf();
        self::getRequest();
        self::distributeRequest();
    }

    private static function pageInit(){
        header("Content-Type:text/html;charset:UTF-8");
        session_start();
    }
    
    private static function dirInit(){
        //文件路径初始化
        define("DS",DIRECTORY_SEPARATOR);
        define("ROOT",getcwd().DS);
    }

    private static function autoLoad(){
        //设置类的自动加载
        spl_autoload_register(function($className){
            $className = str_replace("\\",DS,$className);
            //获取类文件路径名
            $files = array(
                "Controller.class.php",
                ".class.php",
            );
            //循环包含需要的文件
            foreach($files as $file){
                $fileName = ROOT . $className . $file;
                if(file_exists($fileName)){
                    require_once($fileName);
                    break;
                }
            }
        });
    }

    private static function readConf(){
        $GLOBALS['conf'] = require_once("./Base/Conf.php");
    }

    //获取路由参数
    private static function getRequest(){
        $p = isset($_GET["p"]) ? $_GET['p'] : $GLOBALS['conf']['default_plantform'];
        $c = isset($_GET["c"]) ? $_GET['c'] : $GLOBALS['conf']['default_controller'];
        $a = isset($_GET["a"]) ? $_GET['a'] : $GLOBALS['conf']['default_action'];
        define("P",$p);
        define("C",$c);
        define("A",$a);
        //定义视图文件路径
        define("VIEWPATH",ROOT.P.DS."View".DS);
    }

    //分发请求
    private static function distributeRequest(){
        $className = "\\" . P . "\\Controller\\" . C;
        //  \Admin\Controller\Index
        $action = A;

        if(class_exists($className)){
            $Controller = new $className;
        }else{
            echo "c参数错误";
            die();
        }

        if(method_exists($Controller,$action)){
            $Controller->$action();
        }else{
            echo "a参数错误";
            die();
        }
    }

}

basecontroller中代码

<?php
namespace Base;
use Tool\MySmarty;

abstract class BaseController{

    protected $smarty;
    
    public function __construct(){
        $this->smarty = MySmarty::getInstance();
    }

    //验证页面权限
    protected function accessPage(){
        if(isset($_SESSION['userId'])){
            if($_SESSION['admin'] == 1 && P == "Admin");
            else if($_SESSION['admin'] == 0 && P == "Home");
            else{
                $p = $_SESSION['admin'] ? "Admin" : "Home";
                header("location:?p={$p}&c=Index&a=index");
                die();
            }
        }else{
            header("location:?p=Common&c=Login&a=index");
            die();
        }
    }

    //验证接口权限
    protected function accessJson(){
        header("Content-Type:application/json");
        if(isset($_SESSION['userId'])){
            if($_SESSION['admin'] == 1 && P == "Admin");
            else if($_SESSION['admin'] == 0 && P == "Home");
            else{
                $this->sendJsonMessage("操作权限不足",1);
            }
        }else{
            $this->sendJsonMessage("未登陆",1);
        }
    }

    //返回Json信息
    protected function sendJsonMessage($message,$code){
        $message = array("message"=>$message,"code"=>$code);
        echo json_encode($message,JSON_UNESCAPED_UNICODE);
        die();
    }

}

basemodel.class中代码

<?php
namespace Base;
use Tool\Db;

abstract class BaseModel{

    protected $Db;
    protected $table;   //操作的数据表名

    public function __construct(){
        $this->Db = Db::getInstance();
    }

    //获取一条数据
    public function fetchOne($where){
        $sql = "SELECT * FROM {$this->table} WHERE {$where}";
        return $this->Db->query($sql);
    }

    //获取全部数据
    public function fetchAll($where = "2>1"){
        $sql = "SELECT * FROM {$this->table} WHERE {$where}";
        $result =  $this->Db->query($sql);

        //条数为1时,把一维数组转换成二维数组,避免某些foreach循环出错
        if(count($result) == count($result,1) && !empty($result)){
            $result = array($result);
        }

        return $result;
    }

    //获取数据条数
    public function rowCount($where = "2>1"){
        $sql = "SELECT * FROM {$this->table} WHERE {$where}";
        return $this->Db->rowCount($sql);
    }

    //插入数据
    public function insert($data){
        $keys = "";
        $values  = "";
        foreach($data as $key=>$value){
            $keys .= "`{$key}`,";
            if($value == ""){
                $values .= "null,";
            }else{
                $values .= "'{$value}',";
            }
        }
        $keys = rtrim($keys,",");
        $values  = rtrim($values,",");
        $sql = "INSERT INTO {$this->table}({$keys}) VALUE({$values})";
        return $this->Db->exec($sql);
    }

    //更新数据
    public function update($data,$where){
        $update = "";
        foreach($data as $key => $value){
            $update .= "`{$key}`='{$value}',";
        }
        $update = rtrim($update,",");
        $sql = "UPDATE {$this->table} SET {$update} WHERE {$where}";
        return $this->Db->exec($sql);
    }

    //删除数据
    public function delete($where){
        $sql = "DELETE FROM {$this->table} WHERE {$where}";
        return $this->Db->exec($sql);
    }
}

 

 

原帖地址:https://github.com/horvey/library-manager

得先打开浏览器检查功能定位问题