This class was created to query game server which use the Source query protocol, this includes all source games, and all the games that implement Steamworks.
The class also allows you to query servers using RCON although this only works for half-life 1 and source engine games.
Minecraft also uses Source RCON protocol, and this means you can use this class to send commands to your minecraft server while having engine set to Source engine.
- Modern PHP version (7.4 or newer)
- 64-bit PHP or gmp module
- Your server must allow UDP connections
- https://developer.valvesoftware.com/wiki/Server_queries
- https://developer.valvesoftware.com/wiki/Source_RCON_Protocol
AppID | Game | Query | RCON | Notes |
---|---|---|---|---|
~ | All HL1/HL2 games and mods | β | β | |
10 | Counter-Strike 1.6 | β | β | |
440 | Team Fortress 2 | β | β | |
550 | Left 4 Dead 2 | β | β | |
730 | Counter-Strike: Global Offensive | β | β | host_name_store 1; host_info_show 2; host_players_show 2 |
1002 | Rag Doll Kung Fu | β | β | |
2400 | The Ship | β | β | |
4000 | Garry's Mod | β | β | |
17710 | Nuclear Dawn | β | β | |
70000 | Dino D-Day | β | β | |
107410 | Arma 3 | β | β | Add +1 to the server port |
115300 | Call of Duty: Modern Warfare 3 | β | β | |
211820 | Starbound | β | β | Call SetUseOldGetChallengeMethod method after connecting |
244850 | Space Engineers | β | β | Add +1 to the server port |
304930 | Unturned | β | β | Add +1 to the server port |
251570 | 7 Days to Die | β | β | |
252490 | Rust | β | β | |
282440 | Quake Live | β | β | Quake Live uses the ZMQ messaging queue protocol for rcon control. |
346110 | ARK: Survival Evolved | β | β | |
~ | Minecraft | β | β |
Open a pull request if you know another game which supports Source Query and/or RCON protocols.
Add your server to your favourites in Steam server browser, and if Steam can display information about your server, then the protocol is supported.
Connect( $Ip, $Port, $Timeout, $Engine ) | Opens connection to a server |
Disconnect( ) | Closes all open connections |
Ping( ) | Ping the server to see if it exists Warning: Source engine may not answer to this |
GetInfo( ) | Returns server info in an array |
GetPlayers( ) | Returns players on the server in an array |
GetRules( ) | Returns public rules (cvars) in an array |
SetRconPassword( $Password ) | Sets rcon password for later use with Rcon() |
Rcon( $Command ) | Execute rcon command on the server |
Also refer to examples folder to work things out.
PHP Source Query
Copyright (C) 2012-2015 Pavel Djundik
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA