AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
* [安装](https://www.kancloud.cn/idcpj/python/902017#_4) * [git 安装](https://www.kancloud.cn/idcpj/python/902017#git__5) * [composer 安装](https://www.kancloud.cn/idcpj/python/902017#composer__11) * [技巧](https://www.kancloud.cn/idcpj/python/902017#_17) * [Apache 无法识别url](https://www.kancloud.cn/idcpj/python/902017#Apache_url_19) * [Nginx 无法识别url](https://www.kancloud.cn/idcpj/python/902017#Nginx_url_27) * [获取请求中的数据 (类 name="id\[\]" form元素)](https://www.kancloud.cn/idcpj/python/902017#___nameid_form_43) * [闭包(在闭包中传值) 且模型中用静态方法](https://www.kancloud.cn/idcpj/python/902017#___48) * [在模版中关联表中字段](https://www.kancloud.cn/idcpj/python/902017#_61) * [目录结构](https://www.kancloud.cn/idcpj/python/902017#_76) * [配置](https://www.kancloud.cn/idcpj/python/902017#_82) * [扩展配置](https://www.kancloud.cn/idcpj/python/902017#_83) * [场景配置](https://www.kancloud.cn/idcpj/python/902017#_92) * [视图](https://www.kancloud.cn/idcpj/python/902017#_100) * [配置文件](https://www.kancloud.cn/idcpj/python/902017#_102) * [文件上传](https://www.kancloud.cn/idcpj/python/902017#_121) * [模板布局 layout](https://www.kancloud.cn/idcpj/python/902017#_layout_133) > [参考](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; } } ~~~ ### 获取请求中的数据 (类 name="id\[\]" form元素) ~~~ $this->request->post('tid/a'); ~~~ ### 闭包(在闭包中传值) 且模型中用静态方法 ~~~ public static function getLoan($where=array(),$page=0,$sizePage=10,$order=''){ $list = LoanModel::all(function($query) use($where,$page,$sizePage,$order){ $query->where($where)->page($page,$sizePage)->field('id,name,img,min_money,max_money,loan_rate,tip'); if(!empty($order)){ $query->order($order); } }); } ~~~ ### 在模版中关联表中字段 ~~~ //关联member表 public function member(){ return $this->hasOne('MemberModel','uid','uid')->bind(['username'=>'name']); } <volist name="list" id="vo"> <!--输出member表中姓名--> <td>{$vo.member.name}</td> </volist> ~~~ ### 目录结构 ![配置目录格式](https://box.kancloud.cn/fed36da6c9b45f156c24ea8e7320c65c_543x500.png) ## 配置 ### 扩展配置 在`config/extra/email.php`,写入配置参数email会被当作建名. ~~~ //例子: 创建db.php config/extra/databases.php return array( //code ); ~~~ ### 场景配置 在`config/extra/config.php`或`app`中 的`config.php`中 配置`'app_status' => 'office'`, 创建`config/extra/office.php`和`config/extra/home.php` 调节`app_status`的值`office`或`home`的参数.选择不同配置. 在不同场景下 databases 的设置不同 ## 视图 ### 配置文件 ~~~ 'view_replace_str'=>[ '__123__'=>'一二三', ] #在模版中 <h3>__123__</h3> #输出为一二三 ~~~ ~~~ #官方自带 <h3>__URL__</h3> #输出/index/index <h3>__STATIC__</h3> #输出/static <h3>__CSS__</h3> #输出 /static/css <h3>__JS__</h3> #输出 /static/js ~~~ ## 文件上传 ~~~ //配置文件位置 cmf 上传设置可在后台进行设置 //admin.js 包含封装的js //应用 <a href="javascript:uploadOne('apk上传','#thumb','file');" class="btn btn-sm btn-default">选择文件</a> ~~~ ## 模板布局 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