Doors
A door is a game or program the caller leaves the BBS for. Carrier runs two kinds:
| Kind | What it is | Declared with |
|---|---|---|
| Native | A PHP module running in the caller's fiber, with the full Terminal API |
#[Door] on the module class |
| External | A separate program wired to the caller over stdin/stdout, given a drop file | a DoorDefinition in app/Config/doors.config.php |
Both kinds are listed in door menus, checked against ACS, node limits and time left, and
announce DoorEntered / DoorExited events. Source:
DoorManager.php.



- Write a native door
- Add an external door
- Put doors on a menu
- Reference:
#[Door] - Reference:
DoorDefinition - Reference: drop files
- Reference: what happens on launch
Write a native door
-
Generate the class:
php carrier make:door RocketThis writes
app/Doors/Rocket.php: aModulemarked#[Door('rocket', title: 'Rocket')]that echoes keys until Q or Escape. Discovery registers it when the server starts; no config entry is needed. Restartphp carrier serveto pick it up. -
Write the game in
handle(). Draw with the terminal API and read keys with$terminal->readKey(). A sketch, with the game loop left out:use Carrier\Door\Door; use Carrier\Session\Session; use Carrier\Terminal\Terminal; #[Door( 'rocket', title: 'Rocket', description: 'Land it gently.', acs: 'SL20', maxNodes: 4, order: 4, )] final class Rocket extends DoorGame { protected function key(): string { return 'rocket'; } protected function title(): string { return 'Rocket'; } public function handle(Session $session, Terminal $terminal): void { if ($this->needsScreen($terminal, 80, 24)) { return; } // ... play, leaving $score and $fuel ... $rank = $this->recordScore($session, $score, ['fuel' => $fuel]); $this->hallOfFame($session, $terminal, $rank); $terminal->pause(); } } -
To keep scores and saved games, extend
App\Doors\DoorGameinstead ofModule, as above. The board's three games do.
DoorGame helpers
DoorGame.php is the board's base class, not part of the framework.
| Method | Does |
|---|---|
key(): string |
abstract; the door's score key |
title(): string |
abstract; shown in the hall of fame |
recordScore($session, int $score, array $meta = []): int |
Saves a DoorScore row, marks D on the caller's Last Callers entry, returns the score's rank. |
hallOfFame($session, $terminal, ?int $highlightRank = null) |
Prints the top ten for key(), marking the highlighted rank. |
needsScreen($terminal, int $cols = 80, int $rows = 24): bool |
When the caller has no ANSI or a smaller screen: prints why, pauses and returns true. |
Saving state between calls
App\Models\DoorState stores one JSON array per user per door. Hi-Lo keeps credits this way
(HiLo.php):
$state = DoorState::fetch('hilo', $userId) ?? ['credits' => self::STAKE, 'best' => self::STAKE, 'refilled' => date('Y-m-d')];
// ...
DoorState::put('hilo', $userId, $state);DoorScore::top($door, $limit = 10) returns the best scores, highest first. See data
for both models.
Add an external door
-
Add a
DoorDefinitiontoapp/Config/doors.config.php. The board ships one, a PHP script that reads DOOR32.SYS:return new DoorsConfig([ new DoorDefinition( name: 'fortune', title: 'The Oracle (external door)', description: 'A separate program reading DOOR32.SYS over stdio.', command: [PHP_BINARY, root_path('doors/fortune/fortune.php'), '{dropFile}'], cwd: root_path('doors/fortune'), dropFile: 'door32', encoding: 'utf8', maxNodes: 4, order: 90, ), ]); -
Make the program:
- read the drop file named on its command line (or
$CARRIER_DROPFILE); - write to stdout and read keys from stdin;
- echo keys itself: the caller's side is in raw mode;
- expect Enter as a bare CR.
fortune.php does all four in about 80 lines and has no dependency on Carrier.
- read the drop file named on its command line (or
-
Restart
php carrier serve. The door appears on door menus.
DOS doors
The config file contains a commented example that starts a DOS door under DOSEMU:
new DoorDefinition(
name: 'lord',
title: 'Legend of the Red Dragon',
command: ['/usr/bin/dosemu', '-quiet', '-f', '/opt/doors/dosemu.conf', 'D:\\LORD\\START.BAT {node}'],
dropFile: 'door',
maxNodes: 4,
acs: 'SL20',
),Carrier only starts the command and pipes its stdio; setting up DOSEMU, its FOSSIL driver and the drive mapping to the node directory is outside Carrier and is not tested here.
Put doors on a menu
->doors() on a menu inserts every door the caller may enter as numbered options (1–9, then
A–Z, skipping keys the menu already uses), in order, then title order. The board's door
menu (Menus.php):
$menus->define('doors', function (MenuDefinition $menu) {
$menu->title('Door games')->art('doors')->doors()->columns(1);
// ...
});A single door on any menu: $menu->option('L', 'Play LORD')->door('lord');. See
menus.
Reference: #[Door]
Door.php. Put it on a module class.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
name |
string |
required | key used by ->door('name') and in events |
title |
string |
required | menu label |
description |
string |
'' |
description |
acs |
?string |
null |
ACS string the caller must pass; null lets everyone in. See acs. |
maxNodes |
int |
0 |
callers allowed in at once; 0 is no limit |
minMinutes |
int |
0 |
minutes left today the caller needs to enter |
order |
int |
0 |
sort position on door menus (then title) |
The board's doors:
| Door | Class | ACS | Order |
|---|---|---|---|
glowcrawl |
Glowcrawl.php | SL20 |
1 |
viper |
Viper.php | — | 2 |
hilo |
HiLo.php | — | 3 |
fortune |
external, fortune.php | — | 90 |
Reference: DoorDefinition
DoorDefinition.php. Native doors are converted to this
too, with module set.
| Field | Type | Default | Meaning |
|---|---|---|---|
name |
string |
required | key |
title |
string |
required | menu label |
description |
string |
'' |
|
acs |
?string |
null |
as for #[Door] |
maxNodes |
int |
0 |
as for #[Door] |
minMinutes |
int |
0 |
as for #[Door] |
module |
?class-string |
null |
native door module |
command |
?list<string> |
null |
external program and arguments, with placeholders; run without a shell |
cwd |
?string |
null |
working directory |
dropFile |
string |
'door32' |
door, door32, dorinfo or chain (also door.sys, door32.sys, dorinfo1.def, chain.txt) |
commType |
int |
0 |
DOOR32.SYS line 1 |
encoding |
string |
'cp437' |
what the program reads and writes: cp437 or utf8 |
env |
array<string,string> |
[] |
extra environment variables, applied last |
timeout |
int |
0 |
seconds before the program is killed; 0 means the caller's time left (no limit when unlimited) |
order |
int |
0 |
sort position |
Command placeholders
Replaced in every element of command (ExternalDoor.php):
| Placeholder | Value |
|---|---|
{node} |
node number |
{dropFile} |
full path of the drop file |
{dropFileDir} |
the node directory, storage/doors/node<N> |
{userId} |
user number |
{handle} |
handle |
{termWidth}, {termHeight} |
screen size |
{timeLeft} |
minutes left (546 when unlimited) |
{encoding} |
the caller's encoding: utf8 or cp437 |
Environment
The program inherits the server's environment plus:
| Variable | Value |
|---|---|
TERM |
ansi, or dumb when the caller has no ANSI |
COLUMNS, LINES |
screen size |
CARRIER_NODE |
node number |
CARRIER_DROPFILE |
drop file path |
CARRIER_ENCODING |
the caller's encoding |
Encoding and input
- Output is converted between the program's
encodingand the caller's; UTF-8 characters split across reads are held back until complete. - Input CR LF and CR NUL become a bare CR.
- Anything the program writes to stderr is logged as a warning.
- When the caller hangs up the program is killed. When the program exits, Carrier resets colours, shows the cursor and resets the scroll region.
Reference: drop files
Written by DropFileWriter.php to
storage/doors/node<N>/ before each launch, CP437-encoded with CRLF line endings. Layouts follow
the Synchronet wiki. Minutes are capped at 546 everywhere, because legacy doors misbehave with
more. The baud rate is always 38400 and no real COM port or socket handle is passed.
DOOR32.SYS (door32, the default)
| Line | Value |
|---|---|
| 1 | comm type (commType: 0 local, 1 serial, 2 telnet) |
| 2 | comm handle: 0 when comm type is 0, else -1 |
| 3 | 38400 |
| 4 | board name and (Carrier <version>) |
| 5 | user number |
| 6 | real name, or handle when empty |
| 7 | handle |
| 8 | security level |
| 9 | minutes left |
| 10 | emulation: 1 ANSI, 0 ASCII |
| 11 | node |
DOOR.SYS (door)
The 52-line GAP format. Lines Carrier fills with caller data:
| Line | Value |
|---|---|
| 1 | COM0: |
| 2 | 38400 |
| 4 | node |
| 10 | real name, or handle |
| 11 | location, or Unknown |
| 15 | security level |
| 16 | calls |
| 17 | last call (m/d/y), today when none |
| 18 | seconds left |
| 19 | minutes left |
| 20 | GR with ANSI, NG without |
| 21 | screen rows |
| 26 | user number |
| 33, 34 | storage directory |
| 35 | sysop name |
| 36 | handle |
| 43 | last call (m/d/y) |
| 44, 45 | current time (H:i) |
| 50 | Carrier BBS |
| 52 | posts |
The other lines hold fixed values; see doorSys() for each.
DORINFOn.DEF (dorinfo)
The file name carries the node in hex, capped at F: DORINFO1.DEF … DORINFOF.DEF.
| Line | Value |
|---|---|
| 1 | board name |
| 2, 3 | sysop first and last name |
| 4 | COM0 |
| 5 | 38400 BAUD,N,8,1 |
| 6 | 0 |
| 7, 8 | handle, split at the first space into first and last name |
| 9 | location, or Unknown |
| 10 | 1 ANSI, 0 ASCII |
| 11 | security level |
| 12 | minutes left |
| 13 | -1 |
CHAIN.TXT (chain)
WWIV format, 31 lines. Lines with caller data:
| Line | Value |
|---|---|
| 1 | user number |
| 2 | handle |
| 3 | real name, or handle |
| 8 | last call (m/d/y) |
| 9, 10 | screen columns, rows |
| 11 | security level |
| 12, 13 | 1 for a sysop, else 0 |
| 14 | 1 ANSI, 0 ASCII |
| 16 | seconds left |
| 17, 18 | storage directory |
| 22 | board name |
| 23 | sysop name |
| 31 | 38400 |
Reference: what happens on launch
DoorManager::launch() in order:
- Unknown door: "That door is closed."
- ACS fails: "You don't have access to that door."
maxNodesreached: shows the artdoorbusyif the theme has it, else a "seats are taken" message.- Fewer than
minMinutesleft: "You need N minutes left to play." - Counts the player in, sets the caller's activity to
Playing <title>and dispatchesCarrier\Door\DoorEntered($session, $name). - Runs the module, or the external program.
- On an exception other than a hang-up: logs it and tells the caller "The door crashed."
- Always: counts the player out, restores the activity, dispatches
Carrier\Door\DoorExited($session, $name).
Listen for the events with #[EventHandler]; see data.