thinkPHP3:
Laravel5.5:
参考网站:https://laravel-china.org/docs/laravel/5.5
thinkphp3重要目录结构解释:
1.跟目录下的index.php文件:
// 检测PHP环境
if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !');
// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false
define('APP_DEBUG',true);
// 定义应用目录(应用默认入口)
define('APP_PATH','./Application/');
//生成模块,完成需要将此注释
//define('BIND_MODULE', 'Admin');
// 定义应用目录
//define('APP_PATH','./Admin/');(自定义应用入口)
//定义下载目录
define('DOWNLOAD_PATH', str_replace('\\', '/', dirname(__FILE__).'/Public/uploads/'));
// 引入ThinkPHP入口文件
require './ThinkPHP/ThinkPHP.php';
2.Application目录
该目录代表了整个应用,包含后台、前端、缓存(runtime)。
其实应该说application/home目录才是代表整个应用。其中Controller用来存放控制器,Model大多用来存放数据库操作相关代码,View用来存放html相关代码。
3.public目录
该目录用来存放资源文件:css、js、img及客户端上传的文件。
thinkphp3代码执行流程:
比如IndexController.class.php 、index.html如何关联。这里注意IndexController.class.php文件名前的Index要与index.html文件名一致且首字母大写。那么如何加载index.html文件呢,只需在IndexController.class.php文件中的index方法中使用一句$this->display();即可。这里要注意index方法名要与index.html文件名一致。对比如下文件名,观察差异:
IndexController.class.php
index.html(该文件所在目录View/index/index.html)
class IndexController extends Controller {
public function index(){
$this->display();
}
}
可供客户端调用的接口定义:
class IndexController extends Controller {
public function login(){
}
}
如上形式的接口为:http://ip/项目名/index.php/home/index/login