- 环境变量开启调试模式
- 、未开启调试模式的报错页面

- 、开启调试模式的报错页面


- 链接数据库
- 、.env配置
DB_TYPE = mysql
DB_HOST = 127.0.0.1
DB_NAME = tp8
DB_USER = root
DB_PASS = root
DB_PORT = 3306
DB_PREFIX= tp_
2)、代码尝试


- 配置加载
- 、config下的配置文件都是自动加载


- 路由加载
- 、设置伪静态
以nginx为例
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
- 、设置路由 根目录/route/app.php
- 访问
Route::get('hello/:name', 'index/hello');

可选变量,[:year]可传可不传
Route::get('hello/:name/[:year]', 'index/hello');


- 加载视图

出现报错

错误原因没有安装模板引擎
Composer安装命令:composer require topthink/think-view

再次访问

创建view/index/index.html,写入如下内容



1万+

被折叠的 条评论
为什么被折叠?



