Entrance principle of the framework document (a)

First, let's look at the running processes framework:

入口文件 -> 定义常量 -> 引入函数库 -> 自动加载类 -> 启动框架 -> 路由解析 -> 加载控制器 -> 返回结果

qq%e5%9b%be%e7%89%8720170522165322

Entry file index.php

<?php

/*
 * 入口文件
 * 1.定义常量
 * 2.加载函数库
 * 3.启动框架
 */
//定义框架根目录
define('MYFRAME',__DIR__);
//定义框架核心目录
define('CORE',MYFRAME.'/core');
//定义应用目录
define('APP',MYFRAME.'/app');
//定义是否开启调试模式
define('DEBUG',1);

if (DEBUG) {
    ini_set("display_errors", "On");
} else {
    ini_set('display_errors','Off');
}
//引入框架核心函数库
include_once CORE.'/common/functions.php';
//引入框架核心类库
include_once CORE.'/MyFrame.php';

//运行框架
\core\Myframe::run();

Public library core \ common] functions.php

<?php


function p($var)
{
    if(is_bool($var)){
    var_dump($var);
    }elseif (is_null($var)) {
    var_dump(NULL);
    }else{
        echo '<pre>'.print_r($var,true).'</pre>';
    }
}

Framework core files \ conre \ MyFrame.php

<?php

namespace  core;

class MyFrame
{
    static function run()
    {
        p('ok');
    }
}

 

Guess you like

Origin www.cnblogs.com/xiaobingch/p/12464552.html