上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 186 下一页
摘要: 一,result类 <?php /* 统一格式的返回json数据 */ namespace App\Lib\Result; class Result { //success:code值为0,data:数据 static public function Success($data, $code = 2 阅读全文
posted @ 2025-02-15 11:08 刘宏缔的架构森林 阅读(99) 评论(0) 推荐(0)
摘要: 一,查看现有路由: $ php bin/hyperf.php describe:route [DEBUG] [command] Commands registered by Hyperf\Command\Listener\RegisterCommandListener [DEBUG] Event H 阅读全文
posted @ 2025-02-15 11:08 刘宏缔的架构森林 阅读(139) 评论(0) 推荐(0)
摘要: 一,官方文档地址 https://hyperf.wiki/3.1/#/zh-cn/validation 安装: 这个第三方库默认没有安装,需要我们手动安装 $ composer require hyperf/validation 二,封装要用的类 1,app/Lib/BaseValidator.ph 阅读全文
posted @ 2025-02-15 11:07 刘宏缔的架构森林 阅读(266) 评论(0) 推荐(0)
摘要: 一,配置nginx 官方文档地址: https://hyperf.wiki/3.1/#/zh-cn/tutorial/nginx 配置文件: /etc/nginx/site-enabled/hyperf.conf upstream hyperf { # Hyperf HTTP Server 的 IP 阅读全文
posted @ 2025-02-15 11:07 刘宏缔的架构森林 阅读(248) 评论(0) 推荐(0)
摘要: 一,配置数据库 .env中数据库的配置: DB_DRIVER=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=mybase DB_USERNAME=root DB_PASSWORD=mypassword DB_CHARSET=utf8mb4 DB_C 阅读全文
posted @ 2025-02-15 11:06 刘宏缔的架构森林 阅读(124) 评论(0) 推荐(0)
摘要: 一,报错信息: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `news` where `news_id` = 3 limit 1) sql语句从mysql客户端命令可以正常执行,判断问题出在数据库的连接上 阅读全文
posted @ 2025-02-15 11:06 刘宏缔的架构森林 阅读(187) 评论(0) 推荐(0)
摘要: 一,常用的三个作用范围 1, 作用顺序: 实际中间件在工作时,按照注册顺序,路由前处理顺序为由前往后,后处理则由后往前 2,作用范围: 全局中间件: 该中间件以下的路由都可以生效 组路由中间件:对提定的路由组生效 单个路由中间件:对指定的单个路由生效 二,代码例子: 1,中间件代码: package 阅读全文
posted @ 2025-02-12 15:01 刘宏缔的架构森林 阅读(233) 评论(0) 推荐(0)
摘要: 一,代码 1,定义常量的类 Constants/BusinessConstants.php <?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyperf.io * @doc 阅读全文
posted @ 2025-02-09 19:18 刘宏缔的架构森林 阅读(75) 评论(0) 推荐(0)
摘要: 一,安装hyperf/config库 $ composer require hyperf/config config()函数要用到 二,查看.env中的默认设置: 如果.env文件不存在,可以复制.env.example APP_NAME=skeleton APP_ENV=dev DB_DRIVER 阅读全文
posted @ 2025-02-09 19:17 刘宏缔的架构森林 阅读(291) 评论(0) 推荐(0)
摘要: 一,修改composer.json "autoload": { "psr-4": { "App\\": "app/" }, "files": [ "app/Functions.php" ] }, 在files数组中增加我们的函数文件 二,源代码 app/Functions.php <?php use 阅读全文
posted @ 2025-02-09 19:17 刘宏缔的架构森林 阅读(124) 评论(0) 推荐(0)
上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 186 下一页