Skip to content

Installation

tilttek/journal
composer require tilttek/journal

The package needs PHP 8.5 or later, with the mbstring extension, and tilttek/player-knowledge.

An application gives Journal:

  • a Contract\JournalStoreInterface that keeps the entries in its database;
  • the Knowledge service of tilttek/player-knowledge, which the journal asks whether a secret is one of the campaign before it hides a block behind it;
  • a Contract\PageDirectoryInterface that says which page of the campaign's world a name leads to, or nothing, and every mention reads as plain text;
  • a Contract\SessionEventSourceInterface that gives what happened in a session, or nothing, and assemble() is refused;
  • a Contract\JournalObserverInterface, to send its messages, or nothing.

The service keeps no state between calls, so one instance serves every request of a long-running worker. A reader is a Reader: a person and a KnowledgeSnapshot of tilttek/player-knowledge, read at the start of a request, passed to each call that reads the journal, and dropped with the request, never kept in a service.

A journal that is not a campaign's — a solo game, a table's board games — still reads through a snapshot: one of Knowledge::snapshot() for the journal's identifier, which holds no secret until the application records one.

Store\InMemoryJournalStore keeps the entries in memory, for tests.