opengsq/opengsq-php

为查询游戏服务器设计的PHP库。

v0.0.3 2024-02-05 21:49 UTC

README

PHP Composer GitHub license Packagist Version Packagist Downloads

OpenGSQ PHP库为PHP语言编写的应用程序提供了一种方便的方法来查询服务器。

文档

详细文档可在 https://php.opengsq.com 查找。

系统要求

安装

推荐通过Composer安装OpenGSQ PHP库,Composer是PHP中的依赖管理工具。您可以在终端中运行以下命令进行安装:

composer require opengsq/opengsq-php

基本用法

以下是一个快速示例,说明如何使用OpenGSQ库通过VCMP协议查询服务器:

<?php

// Include the Composer autoloader
require_once '../vendor/autoload.php';

// Import the Vcmp class from the OpenGSQ\Protocols namespace
use OpenGSQ\Protocols\Vcmp;

// Create a new Vcmp object with the specified host and port
$vcmp = new Vcmp('123.123.123.123', 8114);

// Get the status of the server
$status = $vcmp->getStatus();

// Output the status information
var_dump($status);

// Get the players on the server
$players = $vcmp->getPlayers();

// Output the player information
var_dump($players);

在这个例子中,我们首先包含Composer自动加载器并导入Vcmp类。然后创建一个新的Vcmp对象,指定要查询的服务的地址和端口。最后,我们调用getStatusgetPlayers方法来检索和输出关于服务器及其玩家的信息。

许可证

本项目采用MIT许可证。有关详细信息,请参阅LICENSE文件。

随时间变化的星标数量

Stargazers over time