The foreign function interface

The foreign function interface is how module code reaches the platform. It exposes GameDash's capabilities as ordinary PHP classes under the \GameDash\Sdk\FFI namespace, and it is the only route a module has to the host.

That constraint is deliberate. Because modules go through the FFI rather than touching nodes directly, one module works across every platform GameDash supports.

The shape of it

The interface is organised around the things you act on rather than the operations you perform.

Instances\GameDash\Sdk\FFI\Instance. The entry point for almost everything a service module does. Instances::get( $id ) resolves one from an id, and from there you reach its process, console and settings.

Processes and child processes\GameDash\Sdk\FFI\Infrastructure\Node\Process\ChildProcess. An instance's process, and the child processes under it. This is where a game server actually gets spawned, stopped and inspected.

Consoles — reached through an instance. getIo()->getInput()->send( $line ) writes to the server's stdin, which is how you issue in-game commands such as a save or a shutdown warning.

Settings — also reached through an instance. getSettings()->get( $key )->getValue() returns a value the operator can edit in the panel, which is how modules avoid hard-coding paths, versions and ports.

Nodes and infrastructure — the machine an instance runs on, its processes and its network. Most modules never need this directly.

Exceptions carry meaning

Several FFI calls signal state through exceptions rather than return values, and treating them as failures produces modules that log noise and report the wrong status:

  • ChildProcessNotRunningException — the process is already stopped. Expected when stopping.
  • ChildProcessNotFoundException — there is no such child process. Means "offline", not "broken".

Catch both and translate them into state. Example service module shows the pattern.

The gateway is not the FFI

Worth keeping straight: the gateway is how a caller passes data into your resource — an instance.id, typically. The FFI is how your resource reaches out to the platform. You use the gateway once, in the constructor, to find out what you are acting on; you use the FFI everywhere after that.

Full class reference

Every class, method, parameter and return type is listed in the generated reference:

FFI class reference

That page is generated from the SDK itself, so it stays current in a way prose cannot. Use this article for the shape of the interface and that one for signatures.