composer require knik/gameap-daemon-client$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();$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)$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();$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
)
)
*/$result = $gdaemonFiles->listFiles('/path/to/dir');
print_r($result);
Array
(
[0] => directory
[1] => file.txt
)$gdaemonFiles->mkdir('/path/to/new_dir');$gdaemonFiles->delete('/path/to/file.txt');To remove a directory that contains other files or directories:
$gdaemonFiles->delete('/path/to/file.txt', true);Rename or move files/directories
$gdaemonFiles->rename('/path/to/file.txt', '/path/to/new_name.txt');$gdaemonFiles->copy('/path/to/file.txt', '/path/to/new_file.txt');$gdaemonFiles->chmod(0755, '/path/to/file.txt');$gdaemonFiles->exist('/path/to/file.txt');$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
)
*/$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);$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');$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();Get GameAP Daemon version and compilation date
$version = $gdaemonStatus->version();Get uptime info, number of working and waiting tasks, number of online servers list
$info = $gdaemonStatus->infoBase();Get uptime info, ID list of working and waiting tasks, ID list of online servers list
$info = $gdaemonStatus->infoDetails();
