graze/dynamark3-client

此软件包最新版本(v2.1.0)没有可用的许可信息。

PHP编写的 Dynamark 通信协议 3 客户端

v2.1.0 2019-05-03 01:38 UTC

This package is auto-updated.

Last update: 2024-09-04 22:34:47 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP编写的 Dynamark 通信协议 3 客户端

安装

通过 Composer

composer require graze/dynamark3-client

使用方法

实例化客户端

使用 factory 方法返回一个 Dynamark3ClientInterface 实例

$client = Graze\Dynamark3Client\Dynamark3Client::factory();
...

执行命令

使用 connect 连接到远程端点

...
$dsn = '127.0.0.1:20000';
$client->connect($dsn);
...

命令是可以在客户端直接调用的方法名

...
// issue a GETXML command
$resp = $client->getxml();
...

包含空格的命令使用 驼峰命名法 表示

...
// issue a MARK STOP command
$resp = $client->markStop();
...

命令参数作为方法参数传递

...
// issue a DELETEFILE command
$path = '\hard disk\domino\filecoding\codes.txt';
$resp = $client->deletefile($path);
...

响应

客户端将返回一个包含以下方法的 Dynamark3ResponseInterface 对象

/**
 * Any response from the server up until a prompt is encountered.
 *
 * @return string
 */
public function getResponseText();

/**
 * Whether an error prompt was encountered.
 *
 * @return bool
 */
public function isError();

/**
 * The error code returned from the Dynamark 3 server
 *
 * @return int
 */
public function getErrorCode();

处理响应

...
$resp = $client->getxml();
if ($resp->isError()) {
    echo sprintf('the server responded with error code: [%d]', $resp->getErrorCode());
    // look up the error code in the Dynamark 3 protocol docs
    return;
}

$xml = $resp->getResponseText();
// do something fun with the xml

示例成功响应

Screenshot of terminal text showing a success response

示例错误响应

Screenshot of terminal text showing an error response

某些命令在其响应中会返回有趣的数据,例如 getxml

Screenshot of terminal text showing XML response

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

测试

make test

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全性

如果您发现任何安全相关的问题,请通过电子邮件 security@graze.com 报告,而不是使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件