zoukankan      html  css  js  c++  java
  • php auto_load mvc 接口框架(原创)

    autoload.php

    <?php
    function framework_autoload($className){
        $className=str_replace('\','/',$className);
        include_once($className.'.class'.'.php');
    }
    spl_autoload_register('framework_autoload');

    init.php

    <?php
    require_once($_SERVER['DOCUMENT_ROOT'] . "/comm.php");
    
    // 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false
    define('APP_DEBUG',true);
    APP_DEBUG?error_reporting(E_ALL):error_reporting(0);
    
    // 定义应用目录
    define('APP_PATH',$_SERVER['DOCUMENT_ROOT'] . "/new_framework/");
    
    //定义按照类名自动加载的include起始路径
    $autoLoadIncludePath=array(APP_PATH);
    set_include_path(get_include_path() . PATH_SEPARATOR .implode(PATH_SEPARATOR,$autoLoadIncludePath));
    
    //php自动加载
    require_once(APP_PATH."BLL/autoload.php");
    
    //mvc 处理
    $c=$_REQUEST['c'];
    $controller='Controller\'.$c.'Controller';
    $action=$_REQUEST['a'];
    if(!class_exists($controller)){
        $res['code']=1000;
        $res['msg']=$c.'控制器不存在!';
    }else if(!method_exists($controller,$action)){
        $res['code']=1001;
        $res['msg']=$action.'方法不存在!';
    }else{
        $controllerObj=new $controller();
        $res=$controllerObj->$action();
    }
    echo json_encode($res);
  • 相关阅读:
    CentOS7安装注意
    ES插件安装
    CentOS7命令
    ES安装手册
    五 、redis-cluster java api
    四 、Redis 集群的搭建
    三 redis 的 java api(jedis)
    C#验证码 使用GDI绘制验证码
    云时代架构阅读笔记二——Java性能优化(二)
    【转载】Asp .Net Web Api路由路径问题
  • 原文地址:https://www.cnblogs.com/zhudongchang/p/4353715.html
Copyright © 2011-2022 走看看