一、下载tp6
composer create-project topthink/think tp6
单应用模式
二、TP6 多应用模式
重点!!! 删除app 原来controller目录 或改名
1> config/app.php 添加
‘auto_multi_app’ => true//2020/11/11 开启多应用
2> composer 在项目根目录 安装多应用模式扩展 think-multi-app
composer require topthink/think-multi-app
3> php think build demo
demo是应用名称 可以用admind、index等
出现 successed 即可成功
即可看到 app 下 有demo 和index 各一套控制器以及页面
http://www.tp6.com/index.php/demo/index
http://www.tp6.com/index.php/index/index
http://www.tp6.com/index.php/admin/index
修改.htaccess文件,隐藏index.php
注意:修改的是public目录下的.htaccess文件
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^(.*)$ index.php/
1
[
Q
S
A
,
P
T
,
L
]
R
e
w
r
i
t
e
R
u
l
e
(
.
∗
)
1 [QSA,PT,L] RewriteRule ^(.*)
1[QSA,PT,L]RewriteRule(.∗) index.php [L,E=PATH_INFO:$1]
再次访问:
http://www.tp6.com/demo/index
http://www.tp6.com/index/index
http://www.tp6.com/admin/index
设置默认应用
在config/app.php中修改配置:
default_app:‘index’
在浏览器中即可访问域名即可访问index模块
http://www.tp66.com/
三、模板页面访问
use thinkfacadeView;
return View::fetch();
Driver [Think] not supported.
需要安装
composer require topthink/think-view
出现successed即可
1
2
3
4
5
6
7
8
9
10class Card { public function index() { $list = DB::name("expert")->limit(10)->select(); View::assign('list',$list); return View::fetch(); } }
数据渲染
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15<!doctype html> <html> <head> <meta charset="utf-8"> <title>Document</title> </head> <body> <ul> {foreach $list as $k=>$v} <li>{$v['expert_name']}</li> {/foreach} </ul> </body> </html>
最后
以上就是可耐心锁最近收集整理的关于Tp6安装以及多应用模式设置的全部内容,更多相关Tp6安装以及多应用模式设置内容请搜索靠谱客的其他文章。
发表评论 取消回复