OpenSimulator REST PHP library and command-line client

Release v1.0.6 (June 13, 2025)
Last Commit 74f25c0 (August 29, 2025 12:00 am)
Repository https://github.com/GuduleLapointe/opensim-rest-php
License AGPL-3.0-or-later

Version 1.0.6 Stable 1.0.6 Requires PHP 7.4 License AGPLv3

This library allows to communicate with Robust or OpenSimulator instance with rest console enabled.

It can be used inside a PHP project, or as a command-line client for OpenSimulator grids.

Available commands can be found here: http://opensimulator.org/wiki/Server_Commands

Prerequisites

Remote connection must be enabled in your Robust .ini file.

Do not leave default values!. You should never need to type username and password manually, so you can safely generate long random strings.

You must choose a specific port, not already used by another service. It is good practice to limit access to this port to authorized IP addresses only in your firewall settings.

[Network]
  ConsoleUser = arandomgeneratedstring
  ConsolePass = anotherrandomgeneratedstring
  ConsolePort = 8009
  ; choose a port not already used by another service

Command-line client

Download the executable from this repository, make sure opensim-rest-cli is executable and move it to /usr/local/bin/.

chmod +x /path/to/opensim-rest-cli
sudo mv /path/to/opensim-rest-cli /usr/local/bin/opensim-rest-cli

You can run commands like

opensim-rest-cli /path/to/Robust.ini show info
opensim-rest-cli /path/to/Robust.ini show regions

If you save the credentials in ~/.opensim-rest-cli.ini, you can skip the Robust.ini argument.

opensim-rest-cli show info
opensim-rest-cli show regions

PHP class

Method 1: Install with composer (recommended for standalone projects)

composer require magicoli/opensim-rest-php

Then in your PHP code:


require_once 'vendor/autoload.php';

$session = opensim_rest_session( array( ‘uri’ => "yourgrid.org:8009", ‘ConsoleUser’ => ‘yourConsoleUsername’, ‘ConsolePass’ => ‘yourConsolePassword’, ) );

if ( is_opensim_rest_error($session) ) { error_log( "OpenSim_Rest error: " . $session->getMessage() ); } else { $responseLines = $session->sendCommand($command); }

Return value: an array containing the line(s) of response or a PHP Error

Method 2: Git Submodule + sparse (recommended for integrated projects)

Setting sparse config is critical to avoid executables being accessible on public website.

From your project directory:


git submodule add https://github.com/magicoli/opensim-rest-php.git opensim-rest
cd opensim-rest
git config core.sparseCheckout true

echo ‘‘ > $(git rev-parse –git-dir)/info/sparse-checkout echo ‘!bin/‘ >> $(git rev-parse –git-dir)/info/sparse-checkout echo ‘!dev/*’ >> $(git rev-parse –git-dir)/info/sparse-checkout echo ‘!opensim-rest-cli.php’ >> $(git rev-parse –git-dir)/info/sparse-checkout echo ‘!composer.lock’ >> $(git rev-parse –git-dir)/info/sparse-checkout

git read-tree -m -u HEAD

This will give you only the files you need:

opensim-rest/
├── class-rest.php
├── composer.json
├── LICENSE
└── README.md

Then in your PHP code:

require_once dirname(__FILE__) . '/opensim-rest/class-rest.php';
// Same usage as above

Method 3: Manual download (not recommended)

You won’t get updates…

Download class-rest.php file in your project or

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)