opengsq / opengsq-php
PHP library designed for querying game servers.
Fund package maintenance!
BattlefieldDuck
Requires
- php: >=8.1.2
Requires (Dev)
- phpunit/phpunit: 10.5.9
This package is auto-updated.
Last update: 2024-10-24 18:35:00 UTC
README
The OpenGSQ PHP library provides a convenient way to query servers from applications written in the PHP language.
Documentation
Detailed documentation is available at https://php.opengsq.com.
System Requirements
- PHP 8.1.2 or higher
Installation
The recommended way to install the OpenGSQ PHP library is through Composer, a tool for dependency management in PHP. You can install it by running the following command in your terminal:
composer require opengsq/opengsq-php
Basic Usage
Here’s a quick example of how you can use the OpenGSQ library to query a server using the VCMP protocol:
<?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);
In this example, we first include the Composer autoloader and import the Vcmp
class. We then create a new Vcmp
object, specifying the host and port of the server we want to query. Finally, we call the getStatus
and getPlayers
methods to retrieve and output information about the server and its players.
License
This project is licensed under the MIT License. See the LICENSE file for details.