tp5中的配置机制

默认在application中,
一个config.php,
一个database.php,
还有一个extra文件夹,里面存放一些零散的配置。

如果在index.php初始化中调整配置路径,
那么extra文件夹也要调整到那个路径中去。

读取配置文件代码,

<?php

/**
 *
 * @file   Index.php
 * @date   2016-8-23 16:03:10
 * @author Zhenxun Du<5552123@qq.com>
 * @version    SVN:$Id:$
 */

namespace appadmincontroller;

//use thinkConfig;

class Index extends Common{
    public function _initialize()
    {
        // todo...
//        dump(Config::get());
        dump(config());

    }
    /**
     * 后台首页
     */
    public function index(){
        return $this->fetch();
    }


}

如果使用Config,需要use think/Config;

不同模块下的配置也要在配置目录下建立相应的文件夹,这样就能针对性的获取到配置信息了。

原文地址:https://www.cnblogs.com/jiqing9006/p/7491146.html