首页 > 其他 > 详细

CI框架学习之一 (入口文件解析)

时间:2015-03-23 15:24:32      阅读:215      评论:0      收藏:0      [点我收藏+]
<?php

//定义开发环境 及 及报错级别
define('ENVIRONMENT', 'development');       ######################################改动之一 是否为开发环境

if (defined('ENVIRONMENT'))
{
	switch (ENVIRONMENT)
	{
		case 'development':
			error_reporting(E_ALL);  //开发环境
		break;

		case 'testing':
		case 'production':
			error_reporting(0);      //生产环境
		break;

		default:
			exit('The application environment is not set correctly.');
	}
}

/*
 * 设置系统文件路径 这个路径可以共用
 */
	$system_path = './system';               ######################################改动之二 自定义系统路径

/*
 * 设置应用路径
*/
	$application_folder = 'application';     ######################################改动之三 自定义应用路径

/*
 * --------------------------------------------------------------------
 * 设置默认的控制器
 * --------------------------------------------------------------------
 *
 * 默认情况下你会设置默认的控制器在 routes.php 文件里.
 * 在强制为一个应用硬编码 controller class/function 在这里.  大多数应用而言
 * 不要设置路由在这里
 *
 */
	// 默认控制器所在磁盘路径
	// $routing['directory'] = '';

	// 默认控制器.  例如:  Mycontroller
	// $routing['controller'] = '';

	// 这个控制器函数将被调用.
	// $routing['function']	= '';


/*
 * -------------------------------------------------------------------
 *  定制配置项
 * -------------------------------------------------------------------
 * 它允许你设置自定义的 config
 * 项目去覆盖默认的 config 值 在 config.php 文件中.
 * 
 */
	// $assign_to_config['name_of_config_item'] = 'value of config item';



// --------------------------------------------------------------------
// 用户配置部分结束,这条线下面不要轻易改动
// --------------------------------------------------------------------

/*
 * ---------------------------------------------------------------
 *  解决系统路径平稳升级
 * ---------------------------------------------------------------
 */

	// 设置当前磁的正确路径
	if (defined('STDIN'))
	{
		chdir(dirname(__FILE__));
	}

	if (realpath($system_path) !== FALSE)
	{
		$system_path = realpath($system_path).'/';
	}

	// 确保路径右边有一个正斜线
	$system_path = rtrim($system_path, '/').'/';

	// 验证系统路径的正确性
	if ( ! is_dir($system_path))
	{
		exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
	}

/*
 * -------------------------------------------------------------------
 *  知道相关路径后,设置主要的文件包含内容
 * -------------------------------------------------------------------
 */
	// 当前文件的名字
	define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));

	// 文件扩展
	define('EXT', '.php');

	// 系统路径的定义
	define('BASEPATH', str_replace("\\", "/", $system_path));

	// 当前文件的控制器
	define('FCPATH', str_replace(SELF, '', __FILE__));

	// 系统路径
	define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));


	// 应用路径
	if (is_dir($application_folder))
	{
		define('APPPATH', $application_folder.'/');
	}
	else
	{
		if ( ! is_dir(BASEPATH.$application_folder.'/'))
		{
			exit("Your application folder path does not appear to be set correctly. Please open the following file and correct this: ".SELF);
		}

		define('APPPATH', BASEPATH.$application_folder.'/');
	}

/*
 * --------------------------------------------------------------------
 * 加载引导文件
 * --------------------------------------------------------------------
 */

require_once BASEPATH.'core/CodeIgniter.php';         ######################################改动之四 自定义引导文件(如果有)

/* End of file index.php */
/* Location: ./index.php */





CI框架学习之一 (入口文件解析)

原文:http://blog.csdn.net/wujiangwei567/article/details/44564055

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!