ThinkPHP框架开发微擎应用?
TP5.1
微擎中的site.php
/**
*
* Class YcModuleSite
*/
class YcModuleSite extends WeModuleSite {
public function __call($name, $arguments)
{
include __DIR__.'/public/index.php';
exit;
}
}
ThinkPHP5.1中的index.php
<?php
// [ 应用入口文件 ]
namespace think;
global $_W,$_GPC;
//设置模块名称
defined('MODULE_NAME') or define('MODULE_NAME',$_GPC['m']);
//获取微擎中的do参数,相当于TP中的module
$mod = $_GPC['do'] ? $_GPC['do'] : 'index';
//获取微擎链接中的opt参数,相当于TP中的controller参数名称
$opt = isset($_GPC['opt']) ? $_GPC['opt'] : 'index';
$_GPC['opt'] = $opt = strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $opt), "_"));
//获取微擎链接中的act参数,相当于TP中的action参数名称
$act = isset($_GPC['act']) ? trim($_GPC['act']) : 'index';
// 加载基础文件
require __DIR__ . '/../framework/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
// 执行应用并响应