Search by

sightpress / module-interface

pedrobrazao

Module contracts for SightPress, a powerful CMS for everyone, designed with blind and low-vision creators and audiences in mind. Interfaces and value objects only, written in modern, object-oriented PHP.

Package info

github.com/sightpress/module-interface

Homepage

pkg:composer/sightpress/module-interface

Statistics

Installs: 180

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

0.6.0 2026-11-27 23:33 UTC

This package is auto-updated.

Last update: 2026-11-27 23:33:26 UTC


README

The contracts that every SightPress module implements. SightPress is a powerful CMS for everyone, designed with blind and low-vision creators and audiences in mind, built on modern, object-oriented PHP.

This package holds interfaces and small value objects only. It contains no implementation code and depends only on PSR interfaces. SightPress's own features are built as modules on these contracts, and third-party modules use the same contracts.

It is versioned on its own, with strict semantic versioning: a new major version means a breaking change in a contract.

What's in it

  • ModuleInterface: what every module implements: manifest() and register(ModuleRegistrar $registrar).
  • ModuleManifest and ModuleRequirement: the module's id, version, the modules it needs, and whether it is always on or on by default for new sites.
  • ModuleRegistrar: one typed sub-registrar per kind of addition: services(), routes(), blockTypes(), permissions(), migrations(), adminMenu(), views(), subscribers(), commands(), settings(), search(), dashboard(), assistant(), seo(), sms(), schedule(), translations(), privacy() and placeholders().
  • Block\BlockType: a content block with its schema, HTML and Markdown rendering, optional structured data and its accessibility checks (A11yRule, A11yIssue).
  • Search\*: site search. Modules turn their content into SearchDocuments with a SearchDocumentProvider; a SearchBackend indexes them and answers a SearchQuery with SearchResults, never showing members-only documents to anonymous visitors. Core dispatches a SearchPerformed event after each search.
  • Dashboard\DashboardWidget: a box on the admin dashboard, shown only to people with its permission.
  • Assistant\*: the optional AI assistant (off by default, bring your own key). An AssistantProvider turns an AssistantRequest into an AssistantResponse (StreamingAssistantProvider can also stream it); an AssistantTask writes the prompt and checks the answer, which is only ever an AssistantSuggestion that a person inserts, copies or discards. Failures throw Exception\AssistantException with an AssistantFailure.
  • Event\*: the stable list of events core dispatches (pages, media, menus, accounts, roles, settings, modules, themes …). They carry ids and plain values, never core objects, so modules can listen to them without depending on core.
  • Http\Screens, Http\AdminScreen, Http\PublicScreen, Text\Message: render a module's admin screens and public pages inside the admin panel or the site's theme, with translated titles and notices.
  • Access\Viewer, Site\SiteInfo, Setting\SettingValues, Audit\AuditTrail: who is asking, which site, the site's settings, and the audit log.
  • Seo\SeoProvider and Seo\SeoEntry: a module's public pages in the sitemap, llms.txt and JSON-LD.
  • Schedule\ScheduledJob: background work done by schedule:run.
  • Block\StyledBlockType, BlockStyles, BlockVariant, BlockOption, BlockIcon: style variants, shared options (alignment, background, width, spacing, form layout) and icons.
  • Sms\*: optional text messages. An SmsProvider sends an SmsMessage to a PhoneNumber (E.164, masked everywhere) and looks numbers up; SmsWebhooks reads delivery receipts and STOP replies. Failures throw Exception\SmsException with an SmsFailure.
  • Privacy\*: what a module keeps about people. A PersonalDataProvider per data set describes it (PersonalDataSet: purpose, categories, suggested lawful basis, Retention, ErasureRule), exports a person's records and erases them (UserRef in, ErasureResult counts out); #[PersonalData] marks the fields. CookieDeclaration lists cookies and browser storage, a ProcessorSource names the third parties data goes to while a feature is configured (ProcessorDeclaration), and ConsentManager / ConsentPurpose handle consent. Events UserDataExported, UserErasureScheduled, UserErasureCancelled and UserErased.
  • Placeholder\*: details editors can put in text ({{ acme_events.next_date }}), with a PlaceholderResolver.
  • Block\CodeLanguage, CodeHighlighter, CodeToken: extra languages for the code block.
  • Locale\LocaleFormats, Money\Money + MoneyFormatter, Site\SiteLanguages: dates, numbers and calendar names in the format locale, money by its own currency, and whether the site has more than one language.
  • Value objects: Routing\Route (with an optional permission that core checks and a critical flag for two-step confirmation), Access\Permission, Admin\AdminMenuItem, Setting\Setting, Console\CommandParameter; plus Migration\MigrationProvider and the Console\Command contract.

Access\Permission::$allowedOnSignUp (default false) marks the permissions that a role given to people who register themselves may hold, so sign-up can never grant admin rights.

The value objects check their values when they are built and throw Exception\InvalidValueException with a message that names the field and the rule.

Interfaces that modules implement change only in a major release. Interfaces that core implements (the registrars, Block\BlockContext, Console\CommandInput, Console\CommandOutput, Dashboard\DashboardContext, Assistant\AssistantContext, Http\Screens, Setting\SettingValues, Audit\AuditTrail, Privacy\ConsentManager, Placeholder\PlaceholderContext, Locale\LocaleFormats, Money\MoneyFormatter and Site\SiteLanguages) may gain methods in a minor release, so modules must not implement them.

Requirements

  • PHP 8.5 or later
  • psr/container, psr/http-server-handler and psr/http-server-middleware

Development

This package has no dependencies on the other SightPress repos. To work on it:

composer install
composer check

Composer commands:

  • composer check: everything that must pass before a commit. It validates composer.json, checks the code style, runs static analysis, runs the unit suite with the coverage gate, then runs the integration suite.
  • composer test: both test suites. composer test:unit and composer test:integration run one suite each.
  • composer test:coverage: the unit suite with coverage. It fails if unit tests cover less than 100% of the lines or methods in src/, and it lists what is not covered. @codeCoverageIgnore is not allowed. The HTML report is written to build/coverage/html/.
  • composer fix: applies Rector refactorings, then fixes the code style.

Coverage needs the PCOV extension, or Xdebug in coverage mode. If your PHP has neither, use the development image from the core repo (docker/dev-php/), which has PHP 8.5, PCOV and Composer. With core cloned next to this repo, run this from this folder:

docker build -t sightpress/dev-php:8.5 ../core/docker/dev-php
docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/workspace" -w /workspace \
  sightpress/dev-php:8.5 composer check

Continuous integration

Every pull request and every push to main runs the CI workflow (composer check): composer validate, code style, PHPStan, the unit suite with the 100% coverage gate, the integration suite and composer audit. The coverage report is uploaded as an artifact.

Commit messages follow Conventional Commits; release-please uses them to keep a release pull request and CHANGELOG.md up to date.

main is protected by the ruleset in .github/rulesets/main.json. Changes reach it only through a pull request that passes the composer check check and has one approval. Pull requests are squash-merged. Admins can bypass the ruleset.

Contributing

Everyone can help, not only developers. See CONTRIBUTING.md for the ways to take part, and the Code of Conduct that everyone who takes part agrees to follow.

Licence

GNU General Public License v3.0 or later. See LICENSE.