首页 > TAG信息列表 > Hyperf

docker 执行

命令   docker-compose -f ./build.yaml up -d build.yaml  文件内容     { "version": "2.1", "services": { "main-service": { "image": "hyperf/hyperf:8.0-alpine-v3.15-swoole", "container_name":

Hyperf 实现redis消息队列-源码解读

   Hyperf 实现redis消息队列-源码解读     之前写过一篇笔记《Redis实现消息队列》,其中对消息队列以及redis实现消息队列的三种方式进行了介绍。下面来对hyperf实现redis消息队列的源码进行解读,加深对redis如何来实现消息队列的理解。     一、实现Redis消息队列的各个文

Hyperf 初体验-汇总

请求与协程生命周期 Swoole 在处理每个连接时,会默认创建一个协程去处理,主要体现在 onRequest、onReceive、onConnect 事件,所以可以理解为每个请求都是一个协程,由于创建协程也是个常规操作,所以一个请求协程里面可能会包含很多个协程,同一个进程内协程之间是内存共享的,但调度顺序

hyperf获取客户端真实ip

        hyperf框架获取客户端真实ip use Hyperf\Utils\ApplicationContext; use Hyperf\HttpServer\Contract\RequestInterface; function getRealIp(): string { $request = ApplicationContext::getContainer()->get(RequestInterface::class);

hyperf如何热启动,热更新,更改代码自动重启

1、热更新 Watcher2、安装 composer require hyperf/watcher –dev3、生成配置文件 php bin/hyperf.php vendor:publish hyperf/watcher 所在目录:config/autoload/watcher.php  4、启动 php bin/hyperf.php server:watch netstat -anp|grep 9501 kill 6653 再运行 php bin/hype

宝塔安装hyperf随记

将php.ini的memory_limit设置大 默认是128M,改成1024Mvim /servers/php/lib/php.ini memory_limit = 1024M 宝塔安装 直接在宝塔里找到对应的php版本,进行可视化安装swoole,并且关闭 Short Name       源码安装 Swoole PHP 扩展 >= 4.5,并关闭 Short Name参考swoole官方安装文

hyperf websocket服务

安装hyperf/websocket-server组件 composer require hyperf/websocket-server websocket服务配置 config/autoload/server.php <?php declare(strict_types=1); use Hyperf\Server\Event; use Hyperf\Server\Server; use Swoole\Constant; return [ 'mode' =

hyperf UDP服务

UDPServer类 app/Server/UdpServer.php <?php declare(strict_types=1); namespace App\Server; use Hyperf\Contract\OnPacketInterface; class UdpServer implements OnPacketInterface { //监听数据接收事件 public function onPacket($server, $data, $clientInf

hyperf TCP服务

TcpServer类 app/Server/TcpServer.php <?php declare(strict_types=1); namespace App\Server; use Hyperf\Contract\OnReceiveInterface; class TcpServer implements OnReceiveInterface { //监听链接事件 public function onConnect($server,int $fd){

hyperf 数据库模型-修改器

访问器 Index控制器 app/Controller/IndexController.php <?php namespace App\Controller; use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Annotation\AutoController; use App\Model\User; /** * @AutoController(); */ class IndexCo

hyperf 数据库模型缓存

安装模型缓存组件 composer require hyperf/model-cache 控制器 app/Controller/IndexController.php <?php namespace App\Controller; use Hyperf\HttpServer\Contract\RequestInterface; use Hyperf\HttpServer\Annotation\AutoController; use App\Model\User; /** *

hyperf 数据库模型-model操作

生成model php bin/hyperf.php gen:model user User model app/Model/User.php <?php declare (strict_types=1); namespace App\Model; use Hyperf\DbConnection\Model\Model; /** */ class User extends Model { /** * The table associated with the mode

hyperf数据库模型-1

安装数据库组件 composer require hyperf/db-connection 数据库配置 <?php declare(strict_types=1); return [ 'default' => [ 'driver' => env('DB_DRIVER', 'mysql'), 'host' => env('DB_HO

hyperf 验证器

安装validation composer require hyperf/validation 安装translation composer require hyperf/translation 生成translation配置文件 php bin/hyperf.php vendor:publish hyperf/translation 生成validation配置文件 php bin/hyperf.php vendor:publish hyperf/validation 生成

hyperf 视图 smarty 模板引擎

安装视图 composer require hyperf/view 安装 Smarty 引擎 composer require smarty/smarty 安装task composer require hyperf/task 控制器 app/Controller/ViewController.php <?php declare(strict_types=1); namespace App\Controller; use Hyperf\HttpServer\Contract\Req

hyperf 日志

配置 config/autoload/logger.php <?php declare(strict_types=1); return [ 'default' => [ 'handler' => [ 'class' => Monolog\Handler\StreamHandler::class, 'constructor'

hyperf后台管理系统

hyperf-rbac是什么? hyperf-rbac是一个纯净的后台管理系统,是用hyperf +vue写的,适合二次开发。 源代码链接 下载地址:hyperf-rbac

hyperf 请求

控制器 app/Controller/IndexController.php <?php namespace App\Controller; use Hyperf\HttpServer\Annotation\AutoController; use Hyperf\HttpServer\Contract\RequestInterface; /** * @AutoController(); */ class IndexController { public funct

hyperf 路由

路由配置文件 config/routes.php <?php use Hyperf\HttpServer\Router\Router; // 下面三种方式的任意一种都可以达到同样的效果 Router::get('/hello-hyperf', 'App\Controller\IndexController::hello'); Router::get('/hello-hyperf', 'App\Controller\

hyperf 注解

注释和注解区别 注释:给程序员看,帮助理解代码,对代码起到解释、说明的作用。 注解:给应用程序看,用于元数据的定义,单独使用时没有任何作用,需配合应用程序对其元数据进行利用才有作用。 注解方式 类 测试代码(app/indexController/test) <?php declare(strict_types=1); namespace A

hyperf 配置

添加配置(author) config/config.php <?php declare(strict_types=1); use Hyperf\Contract\StdoutLoggerInterface; use Psr\Log\LogLevel; return [ 'app_name' => env('APP_NAME', 'skeleton'), 'app_env' =>

hyperf 协程理解和使用

协程是一种轻量级的线程,由用户代码来调度和管理,而不是由操作系统内核来进行调度,也就是在用户态进行 创建协程方法 co函数 public function test(){ echo "first id: ". Coroutine::id().PHP_EOL; co(function () { echo "second id: ". Coroutine::id().PHP_EOL;

hyperf 处理百万数据单元测试案例

场景:有一批数据没有推到中间件,需要我这里搞一个脚本,大约有600万数据。我开始比较蠢的方法是将文件拆分,然后一条一条读。一条一条请求,速度很慢,如果因为某些因素中断程序,虽然有日志,但是还是要将已经跑过的数据去除,很麻烦 后来领导说放redis,然后用hyperf协程搞。 为啥这样搞,red

Hyperf 异常处理器

本文章主要针对token验证的异常处理 1.自定义异常 在项目app/Exception/Handler/下,创建一个JwtExceptionHandler.php文件 touch app/Exception/Handler/JwtExceptionHandler.php 2.JwtExceptionHandler.php文件内容 <?phpnamespace App\Exception\Handler;use Hyperf\Exception

Hyperf-消息队列

Hyperf-消息队列      官方文档里面有详细说明,安装和配置不再赘述,这里只是记录下实际中使用Redis异步队列的具体使用。      工作原理      ConsumerProcess 是异步消费进程,会根据用户创建的 Job 或者使用 @AsyncQueueMessage 的代码块,执行消费逻辑。 Job 和 @AsyncQueue