yggverse/nps
最新稳定版本:1.3.1
Composer 安装命令:
composer require yggverse/nps
包简介
PHP 8 Library for NPS Protocol
README 文档
README
Archived!
Use Ratchet IoServer - asynchronous WebSocket in PHP as more featured replacement to this library.
nps-php
PHP 8 / Composer Library for NPS Protocol
Like Titan for Gemini, NPS is the satellite for NEX protocol (see also nex-php)
it listen for single dot in line to signal the package ending.
Specification
nex://nightfall.city/nps/
Usage
composer require yggverse/nps
Server
Build interactive server instance to listen NPS protocol connections!
$server = new \Yggverse\Nps\Server;
Provide optional host, port, size, line and live arguments in constructor:
$server = new \Yggverse\Nps\Server('127.0.0.1', 1915);
Alternatively, use following setters after object initiation
Server::setHost
Bind server host to listen incoming connections, 127.0.0.1 by default
Server::getHost
Get current server host
Server::setPort
Bind server port to listen incoming connections, 1915 by default
Server::getPort
Get current server port
Server::setSize
Set total content length limit by mb_strlen, 0 by default (unlimited)
Server::getSize
Get current content length limit
Server::setLine
Set packet line limit in bytes passing to fread, 1024 by default
Server::getLine
Get current packet line limit
Server::setLive
Set server status true|false to shutdown immediately
Server::getLive
Get current server status
Server::setWelcome
Define application logic on peer connection established
$server->setWelcome( function ( string $connect ): ?string { printf( "connected: %s\n\r", $connect ); return sprintf( "welcome, %s\n\r", $connect ); } );
Server::getWelcome
Get current Welcome function, null by default
Server::setPending
Define application logic on peer make initial request
$server->setPending( function ( string $request, string $connect ): ?string { printf( 'connection: %s requested: %s', $connect, $request, ); return sprintf( 'received: %s', $request ); } );
Server::getPending
Get current Pending function, null by default
Server::setHandler
Define basic application logic on complete packet received
- could be also defined as Server::start argument
$server->setHandler( function ( bool $success, string $content, string $request, string $connect ): ?string { printf( 'connection: %s request: %s', $connect, $request ); if ($success) { var_dump( $content ); } return 'thank you!'; } );
Server::getHandler
Get current Handler function, null by default
Server::start
Run server object
$server->start();
Optionally, define handler function as the argument to process application logic dependent of client request
$server->start( function ( bool $success, string $content, string $request, string $connect ): ?string { printf( 'connection: %s request: %s', $connect, $request ); if ($success) { var_dump( $content ); } return 'thank you!'; // null|string response } );
Server::stop
Stop server instance.
Same to Server::setLive(false)
Testing
nc 127.0.0.1 1915- connect server usingnctest- enter the target pathYOUR MESSAGE GOES HERE- enter the message text.- commit package with dot
To send any file:
test ╦ ╦╔═╗╔═╗╔╦╗╦═╗╔═╗╔═╗╦╦ ╚╦╝║ ╦║ ╦ ║║╠╦╝╠═╣╚═╗║║ ╩ ╚═╝╚═╝═╩╝╩╚═╩ ╩╚═╝╩╩═╝ .
cat file.txt | nc 127.0.0.1 1915
yggverse/nps 适用场景与选型建议
yggverse/nps 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「server」 「NPS」 「yggverse」 「nps-protocol」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 yggverse/nps 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yggverse/nps 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 yggverse/nps 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Php SDK for Ingenico ePayments - NPS LatAm Services
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Library for displaying NPS in plugins.
Laravel nps
A jQuery augmented PHP library for creating and validating HTML forms
annotations-scan-plugin
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-24