microwin7 / rcon
适用于 PHP 的简单 Rcon 类。
v1.1.0
2023-07-24 00:40 UTC
This package is auto-updated.
Last update: 2024-09-24 03:09:43 UTC
README
适用于 PHP 的简单 Rcon 类。
安装
使用 Composer
可以使用以下命令安装此 Rcon 库:
$ composer require thedudeguy/rcon
不使用 Composer
如果不使用 Composer,只需将 Rcon.php 文件放置在您的项目中,并在您的 PHP 脚本中包含它
require_once('Rcon.php');
示例
为了使此脚本正常工作,必须在服务器上启用 rcon,通过在服务器的 server.properties
文件中将 enable-rcon=true
设置为 true。还必须设置一个密码,并在脚本中提供。
$host = 'some.minecraftserver.com'; // Server host name or IP $port = 25575; // Port rcon is listening on $password = 'server-rcon-password'; // rcon.password setting set in server.properties $timeout = 3; // How long to timeout. use Thedudeguy\Rcon; $rcon = new Rcon($host, $port, $password, $timeout); if ($rcon->connect()) { $rcon->sendCommand("say Hello World!"); }