ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] > [参考](https://www.kancloud.cn/manual/thinkphp5/content) ## 安装 ### git 安装 ``` git clone --depth=1 https://github.com/top-think/think.git think_git cd think_git git clone --depth=1 https://github.com/top-think/framework.git thinkphp ``` ### composer 安装 ``` composer create-project --prefer-dist topthink/think think_composer ``` ## 技巧 ### Apache 无法识别url >自带.htaccess 无效 ``` `RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 修改为 RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]` ``` ### Nginx 无法识别url > [参考url](http://www.sou-xun.com/show/1395199.html) ``` location / { index index.html index.htm index.php; #autoindex on; # 加入此行代码 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } ``` ## 模板布局 layout 1. 开启 layout ``` 'template' => [ 'layout_on' => true, 'layout_name' => 'layout', 'layout_item' => '{__CONTENT__}', ] ``` 2. view 的根目录建立layout.html 文件,并写入一下内容 ``` {include file="public/header" /} {__CONTENT__} {include file="public/footer" /} ``` 3. 在view 的其他目录中只需要写相关信息 不需要在用include 引入head头和fllter