随笔分类 - hyperf
1
基于swoole的web框架
摘要:一,官方文档 https://hyperf.wiki/3.1/#/zh-cn/controller?id=%e9%81%bf%e5%85%8d%e5%8d%8f%e7%a8%8b%e9%97%b4%e6%95%b0%e6%8d%ae%e6%b7%b7%e6%b7%86 二,代码例子: 1,中间件 <
阅读全文
摘要:一,安装用到的库: 1,官方文档地址: https://hyperf.wiki/3.1/#/zh-cn/phar 2,安装phar库 $ composer require hyperf/phar ./composer.json has been updated Running composer up
阅读全文
摘要:一,result类 <?php /* 统一格式的返回json数据 */ namespace App\Lib\Result; class Result { //success:code值为0,data:数据 static public function Success($data, $code = 2
阅读全文
摘要:一,查看现有路由: $ php bin/hyperf.php describe:route [DEBUG] [command] Commands registered by Hyperf\Command\Listener\RegisterCommandListener [DEBUG] Event H
阅读全文
摘要:一,官方文档地址 https://hyperf.wiki/3.1/#/zh-cn/validation 安装: 这个第三方库默认没有安装,需要我们手动安装 $ composer require hyperf/validation 二,封装要用的类 1,app/Lib/BaseValidator.ph
阅读全文
摘要:一,配置nginx 官方文档地址: https://hyperf.wiki/3.1/#/zh-cn/tutorial/nginx 配置文件: /etc/nginx/site-enabled/hyperf.conf upstream hyperf { # Hyperf HTTP Server 的 IP
阅读全文
摘要:一,配置数据库 .env中数据库的配置: DB_DRIVER=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=mybase DB_USERNAME=root DB_PASSWORD=mypassword DB_CHARSET=utf8mb4 DB_C
阅读全文
摘要:一,报错信息: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `news` where `news_id` = 3 limit 1) sql语句从mysql客户端命令可以正常执行,判断问题出在数据库的连接上
阅读全文
摘要:一,代码 1,定义常量的类 Constants/BusinessConstants.php <?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyperf.io * @doc
阅读全文
摘要:一,安装hyperf/config库 $ composer require hyperf/config config()函数要用到 二,查看.env中的默认设置: 如果.env文件不存在,可以复制.env.example APP_NAME=skeleton APP_ENV=dev DB_DRIVER
阅读全文
摘要:一,修改composer.json "autoload": { "psr-4": { "App\\": "app/" }, "files": [ "app/Functions.php" ] }, 在files数组中增加我们的函数文件 二,源代码 app/Functions.php <?php use
阅读全文
摘要:一,定义一个日志group config/autoload/logger.php 'daily' => [ 'handler' => [ 'class' => Monolog\Handler\RotatingFileHandler::class, 'constructor' => [ 'filena
阅读全文
摘要:一,自定义异常类 Exception/BusinessException.php 我们用官方提供的这个现成的类: <?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyper
阅读全文
摘要:一,创建middleware $ php bin/hyperf.php gen:middleware AccesslogMiddleware App\Middleware\AccesslogMiddleware created successfully. 二,配置一个日志 config/autolo
阅读全文
摘要:一,配置 config/autoload/exceptions.php <?php declare(strict_types=1); /** * This file is part of Hyperf. * * @link https://www.hyperf.io * @document http
阅读全文
摘要:一,配置日志 在config/autoload/logger.php中增加一项对日志的配置: 'daily' => [ 'handler' => [ 'class' => Monolog\Handler\RotatingFileHandler::class, 'constructor' => [ '
阅读全文
摘要:一,创建controller $ php bin/hyperf.php gen:controller ImageController App\Controller\ImageController created successfully. 配置路由: Router::addGroup('/image
阅读全文
摘要:一,安装第三方库 $ composer require hyperf/watcher --dev 二,配置 1,生成配置文件: $ php bin/hyperf.php vendor:publish hyperf/watcher [hyperf/watcher] publishes [config]
阅读全文
摘要:一,查看帮助 $ php bin/hyperf.php help 二,查看可用的命令: $ php bin/hyperf.php 三,创建一个命令 $ php bin/hyperf.php gen:command DemoCommand 代码如下: <?php declare(strict_type
阅读全文
摘要:一,官网: https://www.hyperf.io/ 二,安装: composer create-project hyperf/hyperf-skeleton 问到的一些问题和我的设置: Creating a "hyperf/hyperf-skeleton" project at "./hype
阅读全文
1
浙公网安备 33010602011771号