navarr/sockets 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

navarr/sockets

Composer 安装命令:

composer require navarr/sockets

包简介

Sockets in PHP

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License
Tests Code Coverage Mutation Score

Sockets is a PHP Library intent on making working with PHP Sockets easier, including the creation and management of a Socket Server.

Work in Progress

The code is currently still a work in progress, with the Socket class itself not yet fully complete. There is a lot I still need to understand about how sockets work both in PHP and probably in C in order to make everything work amazingly.

Not everything is tested yet, and not everything works properly yet.

It is advised not to seriously use this until I create git tag 1.0.0. There will be breaking changes before then.

Usage of SocketServer

Using SocketServer is supposed to be an easy and trivial task (and the class should be documented enough to understand what it's doing without me).

Example of an ECHO Server

<?php

use Navarr\Socket\Socket;
use Navarr\Socket\Server;

class EchoServer extends Server
{
    const DEFAULT_PORT = 7;

    public function __construct($ip = null, $port = self::DEFAULT_PORT)
    {
        parent::__construct($ip, $port);
        $this->addHook(Server::HOOK_CONNECT, array($this, 'onConnect'));
        $this->addHook(Server::HOOK_INPUT, array($this, 'onInput'));
        $this->addHook(Server::HOOK_DISCONNECT, array($this, 'onDisconnect'));
        $this->run();
    }

    public function onConnect(Server $server, Socket $client, $message)
    {
        echo 'Connection Established',"\n";
    }

    public function onInput(Server $server, Socket $client, $message)
    {
        echo 'Received "',$message,'"',"\n";
        $client->write($message, strlen($message));
    }

    public function onDisconnect(Server $server, Socket $client, $message)
    {
        echo 'Disconnection',"\n";
    }
}

$server = new EchoServer('0.0.0.0');

Development

Documentation

This project uses phpdoc to generate documentation. To generate the documentation, you will need to satisfy some dependencies. First, you need to get graphviz. It is available through most Linux distros, but you can always download it and install it from the site if you aren't on Linux. If you install manually, make sure the binaries are on your PATH somewhere. Next, run the following commands within this directory (assumes you already have composer installed and available on your path as composer).

composer install # this will install all of the development dependencies for this project
vendor/bin/phpdoc -d ./src -t ./docs # this will generate the documentation into a docs directory

navarr/sockets 适用场景与选型建议

navarr/sockets 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 430 次下载、GitHub Stars 达 50, 最近一次更新时间为 2015 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 navarr/sockets 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 navarr/sockets 我们能提供哪些服务?
定制开发 / 二次开发

基于 navarr/sockets 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 50
  • Watchers: 9
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-23