Search by

way4os / w4os-engine

magicoli

OpenSimulator Engine - Framework-agnostic core functionality for OpenSim grids

Package info

github.com/way4os/w4os-engine

pkg:composer/way4os/w4os-engine

Statistics

Installs: 1

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 1

3.0.0-beta.15 2026-11-27 22:48 UTC

README

Stable GitHub Tag GitHub commits since latest release PHP License GitHub Downloads (all assets, all releases) Donate

Framework-agnostic PHP library for OpenSimulator grid management, the core of w4os (Way for OpenSim)

⚠️ Important Notice

This is a pure PHP library - it does nothing by itself!

The OpenSimulator Engine provides core functionality for managing OpenSim grids, but requires a parent application to function. It handles database operations, configuration management, and OpenSim protocol communication, but provides no user interface or web endpoints.

Quick Start for grid/simulator admin

Don't install this directly! Instead, choose a complete solution:

  • w4os CLI - Command-line tools to install and manage your grid or standalone simulator. Includes this engine, web helpers and admin tools.
  • W4OS WordPress Plugin - Complete WordPress integration for OpenSim grids. Best for: Complete integration in a WordPress website.
  • w4os helpers - Provides mainly helpers/ required by OpenSim grids to function properly, as well as minimal webui features. Best for: Separate helpers management, with minimal integration with the website.

Project History

This library consolidates over a decade of OpenSimulator integration work that was previously scattered across multiple projects. While the dedicated engine repository is recent, the functionality has evolved through years of real-world usage in production OpenSim grids.

The code has been battle-tested across different implementations before being organized into this reusable, framework-agnostic library.

What This Library Does

  • ✅ The models of a grid - grids, simulators, services, avatars, regions, parcels, estates: listed, found, changed, the same way (docs/data.md)
  • ✅ The controllers - Robust and OpenSim processes: start, stop, restart, status, console
  • ✅ Configuration - the ini files read as OpenSimulator reads them, written without losing what the person added
  • ✅ Databases - every database asked as itself, wherever the grid keeps it (MySQL, MariaDB)
  • ✅ Provisioning - planners and provisioners that make a grid, a simulator, a region
  • ✅ Scheduling - tasks that run by cron or by pseudo cron, locked, with their last run kept
  • ✅ A contract - resources as JSON:API documents, errors as RFC 9457 problems, an OpenAPI document checked against the models
  • ✅ Security functions, forms, archives (OAR, IAR), health checks

What This Library Does NOT Do

  • ❌ No web interface or HTML pages
  • ❌ No user HTTP request handling
  • ❌ No user authentication
  • ❌ No WordPress or other CMS/framework dependencies

For Developers:

  • Use this engine to build your own OpenSim management applications
  • Integrate OpenSim functionality into existing PHP projects
  • Create custom grid administration tools

Requirements

  • PHP 8.2 or newer
  • PHP extensions curl, filter, intl, json, mbstring, mysqli, pdo, session, simplexml, gettext: sudo apt install php-cli php-curl php-intl php-mbstring php-mysql php-xml
  • optional PHP xmlrpc extension (engine provides properly maintained replacement functions)

Fully tested on:

  • Ubuntu 24.04 and 26.04
  • Debian 12 and 13
  • macOS 13.7.8 and later

The machine and its models

Everything the engine does on a machine goes through an Environment: where the install is (Layout), its processes, its launcher, its consoles, its clock. A front-end makes one, a test makes one with fakes.

use W4OS\Engine\Config\Layout;
use W4OS\Engine\Models\{Grid, Simulator, Service};
use W4OS\Engine\Runtime\Environment;

$environment = Environment::system(Layout::resolve());      // the install of this machine
$grid = Grid::find($environment, 'vonda');
$grid->robust()->isRunning();                                // its Robust (a controller)
$grid->service('asset')->url();                              // a service of the grid, and who serves it
$simulator = $grid->simulator('welcome');
$simulator->service('profile')->url();                       // the service as this simulator reaches it
$grid->start(simulators: true);

A grid has one or several Robust instances, each serving some of its services; a standalone grid has none, its simulator serves everything. The simulators inherit the services of their grid.

Namespace What it is
W4OS\Engine\Models Grid, Simulator, Service (of the machine), Avatar, Region, Parcel, Estate (of a grid's databases)
W4OS\Engine\Controllers RobustController, OpenSimController: the processes that serve
W4OS\Engine\Runtime Environment, Core (an OpenSimulator release), the process table, the launcher
W4OS\Engine\Config Layout (w4os.conf), GridConfig (the files of a grid), ConfigReader, IniEditor
W4OS\Engine\Data Database (the databases of a grid), Connections, OSPDO, Collection
W4OS\Engine\Provisioning planners and provisioners: they answer "what would this be" before "make it"
W4OS\Engine\Scheduling Scheduler, Task: cron and pseudo cron
W4OS\Engine\Api Api, Contract, Problem, Handler: the resources as JSON:API, the errors as RFC 9457, served as a PSR-15 handler; Formats and Endpoints describe what OpenSimulator and the viewers call; Legacy gives the old scripts the standard
W4OS\Engine\Services the services the helpers serve: the search (SearchQuery, SearchRegistry, SearchParser, EventsParser), the offline messages, the currency and the land tools, XML-RPC
W4OS\Engine\Archives, Health, Hypergrid, Network, Security, Forms, Testing archives, health checks, hypergrid links, ports, escaping, forms, fakes

W4OS\Engine\Testing\Machine is a machine that is a folder (a grid demo, two simulators), EnvironmentFake::with($layout) an environment that touches nothing: the suite runs anywhere (composer test).

Developer Installation

As Composer Package

composer require way4os/w4os-engine

As Git Submodule

git submodule add https://github.com/way4os/w4os-engine.git engine

Usage in Code

require 'vendor/autoload.php';   // PSR-4: W4OS\Engine\ is src/; the gettext stand-in and the xmlrpc polyfill load by themselves

On the command line

The tasks (the search index, the events) run by cron or by pseudo cron, at the end of a visit of a site (Scheduler::tick()). Their state and their locks are kept in TasksRoot (OPENSIM_TASKS_ROOT), cron in the state folder of the install by default: a site run by the web server, which cannot write there, gives one of its own (a cache folder of the site). The health of a grid says whether it can be written (cache, tasks); a folder that cannot be is said once in the log, and no task runs. The tasks of the search also lock the search database of the grid, so that two runners with their own folders never read the same simulators at once.

bin/w4os-api (vendor/bin/w4os-api for a project that has the engine) is the API on the command line, for the tools that are not PHP: w4os-api GET /forms/grid, w4os-api --grid=demo GET /monitor format=text. The install is the one of w4os.conf or of the OPENSIM_* variables. The script first reads the .env of the engine and ~/.opensimrc (lib/rc-helpers, read_rc, for any script to source): bash files, run as they are, e.g. to set the PATH so that it is the php you want that runs.

W4OS\Engine\Container\Podman manages Podman containers without a shell. Pass a connection explicitly when targeting a remote Podman service; bin/opensim-container.php is the command-line adapter for Bash callers (vendor/bin/opensim-container.php when installed as a Composer dependency). Container integration tests are opt-in with PODMAN_INTEGRATION=1; CONTAINER_CONNECTION selects the Podman connection and PODMAN_TEST_IMAGE can select the test image.

The texts of the websites of a grid

The texts a website of the grid shows its people (registration, sign-in, account, lost password, email confirmation, the avatars of the grid, and one per code of the problems of the API) are in gettext files, one source for every site (the Grav plugin, w4os): share/languages/w4os-engine.pot and w4os-engine-<locale>.po for cy_GB, de_DE, fr_FR, it_IT, nl_NL and pt_BR. The engine does not translate them: a site turns them into its own format.

The mails the grid sends for the offline messages (an avatar who is away and asked for them, "Send IM to email" in their viewer) are written from templates: share/mail/<language>/offline-<kind>.txt (its Subject: and From:, a blank line, its text) and .html, one pair per kind (message, grid-message, group-notice, group-invitation, inventory-offer, friendship-offer). A file of the same name in the config folder of the install (<etc>/mail/<language>/) is read in its place. A template has no logic: {{grid}}, {{sender}}, {{message}}, {{title}} are replaced, as they are in the text, HTML-escaped in the HTML; the comment at its top lists them. The language is the recipient's (the one their viewer gave Robust), else English.

Each text has a stable key, the msgctxt of the files; the text of a problem code is error_ and the code with _ for -:

use W4OS\Engine\I18n\Catalog;

Catalog::messages('fr_FR');            // ['register_title' => 'Créer mon avatar', ...]: the translated texts only
Catalog::messages('en');               // every text, in English (Catalog::MESSAGES): the fallback
Catalog::messages('fr_FR', fuzzy: false); // without the fuzzy ones (whose English changed since)
Catalog::errorKey($problem['code']);   // 'error_name_taken'
Catalog::statusKey($avatar['status']); // 'status_pending': the status of an avatar (active, disabled, pending)
Catalog::roleKey($avatar['role']);     // 'role_god_like': the role of an avatar (resident, god-like, customer-service, liaison, god)
Catalog::LOCALES;                      // the languages; Catalog::file('fr') is the path of the .po

Placeholders are the ones of printf (%s, %1$s). A text that is not translated yet is left out, so that the site shows the English one.

Documentation

  • Developer Guide - Architecture rules and patterns
  • The data of a grid - the models (avatars, regions, parcels), the collections and the databases
  • The API - the resources, their attributes and what can be written, from the contract (docs/api/openapi.yaml); composer docs makes it again, the descriptions are written in src/Api/Contract.php
  • Migration of the consumers - what was renamed, moved or removed
  • The engine API for the sites of this machine - a site that changes a grid calls the API run as the user of the instances (opensim web GRID api), with a key

Contributing

This library follows strict architectural principles:

  • Framework-agnostic (no WordPress, no Laravel, etc.)
  • Pure data processing (no HTTP input/output)
  • Explicit data passing (no global variables)

See DEVELOPERS.md for complete guidelines.

License

AGPLv3 - See LICENSE file for details.

Support

  • End Users: Get support from the parent project using this engine (W4OS, Helpers)
  • Developers: Create issues for bugs or feature requests https://github.com/way4os/w4os-engine/issues
  • Documentation: Check the parent project documentation first