dynamark3-client
, (*1)
A Dynamark Communication Protocol 3 client, written in PHP, (*2)
Install
Via Composer, (*3)
``` bash
composer require graze/dynamark3-client, (*4)
## Usage
### Instantiating a client
Use the `factory` method to return a `Dynamark3ClientInterface` instance:
``` php
$client = Graze\Dynamark3Client\Dynamark3Client::factory();
...
Issuing commands
Connect to a remote endpoint using connect
:, (*5)
...
$dsn = '127.0.0.1:20000';
$client->connect($dsn);
...
Commands are then simply method names that can be called directly on the client:, (*6)
...
// issue a GETXML command
$resp = $client->getxml();
...
Commands containing spaces are represented using camelCase:, (*7)
...
// issue a MARK STOP command
$resp = $client->markStop();
...
Command arguments are passed as method paramaters:, (*8)
...
// issue a DELETEFILE command
$path = '\hard disk\domino\filecoding\codes.txt';
$resp = $client->deletefile($path);
...
Responses
The client will respond with a Dynamark3ResponseInterface
object with the following methods:, (*9)
/**
* 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();
Handling a response:, (*10)
...
$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
Example success response:, (*11)
, (*12)
Example error response:, (*13)
, (*14)
Some commands will return interesting data in their response, e.g. getxml
:, (*15)
, (*16)
Change log
Please see CHANGELOG for more information what has changed recently., (*17)
Testing
bash
make test
, (*18)
Contributing
Please see CONTRIBUTING for details., (*19)
Security
If you discover any security related issues, please email security@graze.com instead of using the issue tracker., (*20)
Credits
License
The MIT License (MIT). Please see License File for more information., (*21)