Home > php教程 > php手册 > body text

PHP留言板 原生MVC架构+MONGODB数据库

WBOY
Release: 2016-06-06 19:33:17
Original
1218 people have browsed it

原生态的PHPMVC架构,需提前安装mongodb MongoDB /** * 入口文件 * * @version $Id: index.php 2014-3-12 下午2:27:11 zhangzw $ */// 加载路径$dirpath = array(get_include_path(), 'class', 'model', 'config');set_include_path( implode(PATH_SEPARATOR,

原生态的PHP MVC架构, 需提前安装  mongodb MongoDB
/**
 * 入口文件
 *
 * @version $Id: index.php   2014-3-12 下午2:27:11 zhangzw $
 */

// 加载路径
$dirpath = array(get_include_path(), 'class', 'model', 'config');

set_include_path( implode(PATH_SEPARATOR, $dirpath) );

// 自动加载调用类
class ClassLoader{

	/**
	 * 加载类名称
	 * @param string $class_name
	 */
	public static function class_loader($class_name){
		$class_name = strtolower($class_name);
		
		$search = 'cls';
		if( strpos( $class_name, $search) > 0 ){
			$file = str_replace($search, '', $class_name).'_'.$search.'.php';			
			require_once $file;
		}
	}

	/**
	 * 加载模型类
	 * @param string $model_name
	 */
	public static function model_loader($model_name){

		if(strpos( strtolower($model_name), 'model') > 0){
			$file = 'model_'.strtolower($model_name).'.php';
			require_once $file;
		}

	}


}

// 加载类文件
spl_autoload_register(array('ClassLoader', 'class_loader'));

// 加载模型文件
spl_autoload_register(array('ClassLoader', 'model_loader'));

// 初始化
$core = CoreCls::instance();
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!