承接 axios/tpr-workerman 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

axios/tpr-workerman

Composer 安装命令:

composer require axios/tpr-workerman

包简介

Workerman server handler for tpr framework

README 文档

README

Require

Install

composer require axios/tpr-workerman

Usage

workerman.php

  • Simple
<?php
namespace demo;

require_once __DIR__ . '/vendor/autoload.php';

use tpr\App;
use tpr\server\WorkermanServer;

App::registerServer('workerman', WorkermanServer::class);

App::drive('workerman')->run();
  • Complete Example
<?php

declare(strict_types = 1);

namespace demo;

require_once __DIR__ . '/vendor/autoload.php';

use tpr\App;
use tpr\Event;
use tpr\Path;
use tpr\server\WorkermanServer;
use Workerman\Worker;

Path::configurate([
    'root' => __DIR__,
]);

App::debugMode(false);

App::registerServer('workerman', WorkermanServer::class);

App::drive('workerman'); // initialize App before initialize Event

Event::on('worker_init', function (Worker $worker) {
    // handle worker object in here
});

App::workerman()
    ->config([
        'namespace'       => 'app',           // app base namespace, ### this is required ###
        'lang'            => 'zh-cn',         // default language set name
        'cache_time'      => 60,              // global cache time for config&route data
        'force_route'     => false,           // forces use routing
        'remove_headers'  => [],              // remove some header before send response
        // for ServerHandler custom config.
        'server_options'  => [
            'protocol' => 'http', // support websocket | http | tcp | other custom protocol
            'host'     => '0.0.0.0',
            'port'     => 2346,
            'worker'   => 4,      // the number of worker process
            'context'  => [],     // for enable ssl : https://github.com/walkor/Workerman#enable-ssl
            'options'  => [],     // properties of worker. https://github.com/walkor/workerman-manual/blob/master/english/src/worker-development/name.md
        ],
        'response_config' => [],              // response config, see detail on 	pr\models\ResponseModel.

        'default_content_type_cgi'  => 'html', // default content-type on cgi mode
        'default_content_type_ajax' => 'json', // default content-type on api request
        'default_content_type_cli'  => 'text', // default content-type on command line mode

        'dispatch_rule' => '{app_namespace}\{module}\controller\{controller}',  // controller namespace spelling rule
    ])
    ->run();

Events

event name params
worker_init (Workerman\Worker $worker)
worker_start (Workerman\Worker $worker)
worker_reload (Workerman\Worker $worker)
worker_connect (Workerman\Connection\ConnectionInterface $connection)
worker_close (Workerman\Connection\ConnectionInterface $connection)
worker_buffer_full (Workerman\Connection\ConnectionInterface $connection)
worker_buffer_brain (Workerman\Connection\ConnectionInterface $connection)
worker_error (Workerman\Connection\ConnectionInterface $connection, $code, $msg)
worker_message (Workerman\Connection\ConnectionInterface $connection, Workerman\Protocols\Http\Request $request)

License

The project is open-sourced software licensed under the MIT.

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固