随笔分类 -  ThinkPHP6

Thinkphp6相关知识
摘要:启动服务器 php think run 查看版本 php think version 生成控制器 php think make:controller User 生成模型 php think make:model User 生成中间件 php think make:middleware Auth 生成 阅读全文
posted @ 2021-10-18 17:32 胡勇健 阅读(125) 评论(0) 推荐(0) 编辑
摘要:用法 配置文件 config/filesystem.php <?php return [ // 默认磁盘 'default' => env('filesystem.driver', 'local'), // 磁盘列表 'disks' => [ 'local' => [ 'type' => 'loca 阅读全文
posted @ 2021-10-18 17:21 胡勇健 阅读(1516) 评论(0) 推荐(0) 编辑
摘要:用法 cookie配置文件 config/cookie.php <?php // + // | Cookie设置 // + return [ // cookie 保存时间 'expire' => 0, // cookie 保存路径 'path' => '/', // cookie 有效域名 'dom 阅读全文
posted @ 2021-10-18 17:01 胡勇健 阅读(417) 评论(0) 推荐(0) 编辑
摘要:开启session app\middleware.php <?php // 全局中间件定义文件 return [ // 全局请求缓存 // \think\middleware\CheckRequestCache::class, // 多语言加载 // \think\middleware\LoadLa 阅读全文
posted @ 2021-10-18 16:43 胡勇健 阅读(268) 评论(0) 推荐(0) 编辑
摘要:缓存配置 <?php // + // | 缓存设置 // + return [ // 默认缓存驱动 'default' => env('cache.driver', 'file'), // 缓存连接方式配置 'stores' => [ 'file' => [ // 驱动方式 'type' => 'F 阅读全文
posted @ 2021-10-18 16:29 胡勇健 阅读(526) 评论(0) 推荐(0) 编辑
摘要:验证器使用 命令行生成User验证器 php think make:validate User 验证器添加规则 app\validate\User.php <?php declare (strict_types = 1); namespace app\validate; use think\Vali 阅读全文
posted @ 2021-10-18 16:14 胡勇健 阅读(289) 评论(0) 推荐(0) 编辑
摘要:开启调试模式 .env // 设置开启调试模式 APP_DEBUG = true 右下角出现 logo图标,点击可进入详情 阅读全文
posted @ 2021-10-18 15:46 胡勇健 阅读(224) 评论(0) 推荐(0) 编辑
摘要:日志配置 config/log.php <?php // + // | 日志设置 // + return [ // 默认日志记录通道 'default' => env('log.channel', 'file'), // 日志记录级别 'level' => [], // 日志类型记录的通道 ['er 阅读全文
posted @ 2021-10-18 15:26 胡勇健 阅读(1161) 评论(0) 推荐(0) 编辑
摘要:开启调试模式 .env APP_DEBUG = true 异常页面的模板文件 config/app.php 'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl' 手动抛出异常 // 使用think自带异常类抛出异常 阅读全文
posted @ 2021-10-18 15:06 胡勇健 阅读(1002) 评论(0) 推荐(0) 编辑
摘要:php原生模板引擎 模板配置 config/view.php <?php return [ // 模板引擎类型使用Think 'type' => 'PHP', // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 'auto_rule' => 1, // 模板目录名 ' 阅读全文
posted @ 2021-10-18 14:51 胡勇健 阅读(459) 评论(0) 推荐(0) 编辑
摘要:模型定义 mysql 生成user表 create table user( id bigint unsigned NOT NULL AUTO_INCREMENT, name varchar(150) DEFAULT NULL COMMENT '姓名', create_time bigint DEFA 阅读全文
posted @ 2021-10-18 14:10 胡勇健 阅读(343) 评论(0) 推荐(0) 编辑
摘要:连接数据库 数据库环境配置文件 .env [DATABASE] USERNAME = root PASSWORD = root 数据库配置文件 config/database.php <?php return [ // 默认使用的数据库连接配置 'default' => env('database. 阅读全文
posted @ 2021-10-18 00:03 胡勇健 阅读(614) 评论(0) 推荐(0) 编辑
摘要:响应输出 路由直接返回 添加路由响应 route/app.php Route::get('hello/:name', function ($name) { return 'Hello,' . $name . '!'; }); 测试与结果 http://127.0.0.1:8000/hello/huy 阅读全文
posted @ 2021-10-17 12:34 胡勇健 阅读(299) 评论(0) 推荐(0) 编辑
摘要:请求对象 构造方法注入 控制器 app/controller/Index.php <?php namespace app\controller; use think\Request; class Index { protected $request; public function __constr 阅读全文
posted @ 2021-10-17 11:00 胡勇健 阅读(343) 评论(0) 推荐(0) 编辑
摘要:控制器定义 添加控制器 app/controller/User.php <?php namespace app\controller; class User { public function login() { return 'login'; } } 添加路由 route/app.php Rout 阅读全文
posted @ 2021-10-16 20:34 胡勇健 阅读(235) 评论(0) 推荐(0) 编辑
摘要:配置路由 路由配置文件 /route/app.php <?php use think\facade\Route; Route::rule('index/create', 'index/create'); Route::rule('index/read', 'index/read'); Route:: 阅读全文
posted @ 2021-10-15 17:55 胡勇健 阅读(750) 评论(0) 推荐(0) 编辑
摘要:环境变量 设置环境变量 /.env [DATABASE] USERNAME = root PASSWORD = 123456 获取环境变量 app/controller/Index.php <?php namespace app\controller; use app\BaseController; 阅读全文
posted @ 2021-10-15 10:59 胡勇健 阅读(1793) 评论(0) 推荐(0) 编辑
摘要:安装thinkphp composer create-project topthink/think tp 目录结构 www WEB部署目录(或者子目录) ├─app 应用目录 │ ├─controller 控制器目录 │ ├─model 模型目录 │ ├─ ... 更多类库目录 │ │ │ ├─co 阅读全文
posted @ 2021-10-15 10:01 胡勇健 阅读(98) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示