knik/gameap-daemon-client
最新稳定版本:0.6.6
Composer 安装命令:
composer require knik/gameap-daemon-client
包简介
GameAP Daemon PHP Client
README 文档
README
Installation
composer require knik/gameap-daemon-client
Usage
Commands
Connect to server
$gdaemonCommands = new GdaemonCommands([ 'host' => 'localhost', 'port' => 31717, 'serverCertificate' => '/path/to/server.crt', 'localCertificate' => '/path/to/client.crt', 'privateKey' => '/path/to/client.key.pem', 'privateKeyPass' => '1234', 'timeout' => 10, 'workDir' => '/home/user', ]); $gdaemonCommands->connect();
Execute command
$result = $gdaemonCommands->exec('echo HELLO'); var_dump($result); // string(5) "HELLO"
Exit code:
$result = $gdaemonCommands->exec('echo HELLO', $exitCode); var_dump($result); // string(5) "HELLO" var_dump($exitCode); // int(0)
Files
Connect to server
$gdaemonFiles = new GdaemonFiles([ 'host' => 'localhost', 'port' => 31717, 'serverCertificate' => '/path/to/server.crt', 'localCertificate' => '/path/to/client.crt', 'privateKey' => '/path/to/client.key.pem', 'privateKeyPass' => '1234', 'timeout' => 10, ]); $gdaemonFiles->connect();
Listing directory
Detail info about files
$result = $gdaemonFiles->directoryContents('/path/to/dir'); print_r($result); /* Array ( [0] => Array ( [name] => directory [size] => 0 [mtime] => 1542013640 [type] => dir [permissions] => 0755 ) [1] => Array ( [name] => file.txt [size] => 15654 [mtime] => 1542013150 [type] => file [permissions] => 0644 ) ) */
File names only
$result = $gdaemonFiles->listFiles('/path/to/dir'); print_r($result); Array ( [0] => directory [1] => file.txt )
Create directory
$gdaemonFiles->mkdir('/path/to/new_dir');
Remove
$gdaemonFiles->delete('/path/to/file.txt');
To remove a directory that contains other files or directories:
$gdaemonFiles->delete('/path/to/file.txt', true);
Rename
Rename or move files/directories
$gdaemonFiles->rename('/path/to/file.txt', '/path/to/new_name.txt');
Copy
$gdaemonFiles->copy('/path/to/file.txt', '/path/to/new_file.txt');
Change permission
$gdaemonFiles->chmod(0755, '/path/to/file.txt');
Exist checking
$gdaemonFiles->exist('/path/to/file.txt');
Metadata
$result = $gdaemonFiles->directoryContents('/path/to/file.txt'); print_r($result); /* Array ( [name] => file.txt [size] => 43 [type] => file [mtime] => 1541971363 [atime] => 1541971363 [ctime] => 1541971363 [permissions] => 0644 [mimetype] => text/plain ) */
Download file from server
$gdaemonFiles->get('/remote/path/to/file.txt', '/local/path/to/file.txt');
File handle:
$fileHandle = fopen('php://temp', 'w+b'); $gdaemonFiles->get('/remote/path/to/file.txt', $fileHandle);
Upload file
$gdaemonFiles->put('/local/path/to/file.txt', '/remote/path/to/file.txt');
File handle:
$fileHandle = fopen('/local/path/to/file.txt', 'r'); $gdaemonFiles->put($fileHandle, '/remote/path/to/file.txt');
Status
Connect to server
$gdaemonStatus = new GdaemonStatus([ 'host' => 'localhost', 'port' => 31717, 'serverCertificate' => '/path/to/server.crt', 'localCertificate' => '/path/to/client.crt', 'privateKey' => '/path/to/client.key.pem', 'privateKeyPass' => '1234', 'timeout' => 10, ]); $gdaemonStatus->connect();
GameAP Daemon Version
Get GameAP Daemon version and compilation date
$version = $gdaemonStatus->version();
Base Information
Get uptime info, number of working and waiting tasks, number of online servers list
$info = $gdaemonStatus->infoBase();
Details Information
Get uptime info, ID list of working and waiting tasks, ID list of online servers list
$info = $gdaemonStatus->infoDetails();
统计信息
- 总下载量: 7.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-12