PHP code example of fengdangxing / hyperf-nacos

1. Go to this page and download the library: Download fengdangxing/hyperf-nacos library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fengdangxing / hyperf-nacos example snippets


#config/app.php
return [
    //增加该配置
    'fengdangxing' => [
            'nacos' => [
                'namespaceId' => 'ffffkk',//nacos 命名空间
                'cache' => true,//是否启用redis 缓存节点
                'cacheKey' => 'key:rpc_nodes_%s',//用redis 缓存节点 key值 
                'hashKey' => 'TqGvAmpbJX6XttMsFJrDw7F',//增加密钥值
                'periodSeconds' => 60,//容器缓冲时间(k8s默认30s)
                'preStopSleep' => 60,//容器摧毁前增加时间默认30s+preStopSleep  容器将会等待30+preStopSleep 的时候后真实摧毁pod
            ]
        ]
];
#配置路径 config/annotations.php 没有改文件新建
return [
    'scan' => [
        'paths' => [
            BASE_PATH . '/app',
            BASE_PATH . '/vendor/fengdangxing',//增加该配置
        ],
        'ignore_annotations' => [
            'mixin',
            'Notes',
            'Author',
            'Data',
            'Date'
        ],
    ],
];

#该脚本必须移动到 项目根目录 del_worker_process.sh
//rabbitMq
getContainer()->get(OperateNacos::class)->disposeSigterm($this->getQueue());//所有消费Consumer-或者队列名称 消费者 demo-service.Consumer-demo.build.queue.0
//task
getContainer()->get(OperateNacos::class)->disposeSigterm('crontab-dispatcher');//所有定时任务或者定时任务名称 模糊匹配