sightpress / module-template
A starting point for a SightPress module: SightPress is a powerful CMS for everyone, designed with blind and low-vision creators and audiences in mind. Create your own module from it with composer create-project, then make it yours.
Package info
github.com/sightpress/module-template
Type:sightpress-module
pkg:composer/sightpress/module-template
Requires
- php: >=8.5
- sightpress/module-interface: ^0.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phpstan/extension-installer: ^1
- phpstan/phpstan: ^2
- phpstan/phpstan-phpunit: ^2
- phpstan/phpstan-strict-rules: ^2
- phpunit/phpunit: ^13
- rector/rector: ^2
- sightpress/core: 0.4.x-dev || ^0.5@dev
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-26 22:06:35 UTC
README
A starting point for your own SightPress module. SightPress is a powerful CMS for everyone, designed with blind and low-vision creators and audiences in mind, built on modern, object-oriented PHP.
A module adds features to SightPress: pages, admin screens, block types, permissions, settings, search content, sitemap entries and more. The template is an empty module that already passes every check: it installs, shows on the Features screen, and can be turned on and off for each site. It has no example features; you add yours.
The step-by-step tutorial is in the SightPress documentation: Create a module (https://docs.sightpress.org/latest/tutorials/create-a-module/). It builds an "Events" module from this template.
Start
Either use this repository as a template on GitHub (Use this template), or:
composer create-project sightpress/module-template my-module
cd my-module
composer check
If you used Use this template, run mv tools/module.gitattributes .gitattributes and delete
release-please-config.json, .release-please-manifest.json, .github/workflows/release-please.yml and
.github/rulesets/, unless you want them. composer create-project does this for you.
composer check runs the code style, static analysis (PHPStan at level max), the unit tests with a 100% coverage
gate, and the integration tests, which install the module in SightPress (core is a dev dependency) and turn it off and
on for a site.
Make it yours
- Package name: in
composer.json, setname(for exampleacme/events),description,homepageandsupport. - Namespace and class: rename
src/MyModule.phpand its namespace (Acme\MyModule), and updateautoload,autoload-devandextra.sightpress.moduleincomposer.json, the namespace insrc/Migrations.phpand intests/. Then runcomposer dump-autoload. - Id: in the class, set
ID: lower-case words joined by.,_or-, starting with your vendor name, for exampleacme.events. Use the same id as the key underextra.sightpress.featuresincomposer.json. - What people read: under
extra.sightpress.features.<id>, write thename,descriptionandwhen-offthe Features screen shows to site admins, in plain words. - Templates and texts: set
NAMESPACE(lower-case letters, digits and_, for exampleacme_events) and renametranslations/my_module.en-GB.xlfto match. Templates are then@acme_events/…, and texts uset('…', {}, 'acme_events'). - Run
composer checkagain.
What a module may use
Only sightpress/module-interface (SightPress\Module\…). It is the contract between SightPress and its modules:
routes and screens, permissions, block types, settings, migrations, events, search, SEO, scheduled jobs, translations
and more. Never depend on sightpress/core in require; it is a dev dependency for the integration tests only.
If you need something the contract doesn't have, open an issue on
module-interface.
composer.json requires the contract at its latest minor version (^0.5). SightPress lists a module that needs
another version as unavailable, with the reason, and every site keeps working.
Install it in a project
In a SightPress project, add your module as a Composer path repository while you work on it:
composer config repositories.my-module '{"type": "path", "url": "../my-module", "options": {"symlink": true}}' composer require acme/events:@dev bin/sightpress cache:clear bin/sightpress site:module:list <site> bin/sightpress site:module:enable <site> acme.events
Turning a module on for a site runs its database migrations. Turning it off hides everything it adds and keeps its data; site admins can delete the data afterwards on the Features screen.
Notes for module authors
- Accessibility first. Admin screens go in the admin shell through
Screens::admin(), public pages in the site's theme throughScreens::public(). Use real headings, labels for every field, error messages that say how to fix the problem, and nothing that only works with a mouse or only shows by colour. Test with the keyboard alone, at 320 pixels and 400% zoom. - Plain words. Texts people read are short and clear, in British English first, and go through the translations folder.
- Portable migrations. Migrations run on SQLite, MySQL, MariaDB and PostgreSQL: describe the schema with
Doctrine's schema API, never raw engine-specific SQL, and give every migration a working
down(). - Personal data. Store as little as you can, and say in your README what you store and why.
- Never load anything from other sites (fonts, scripts, images) in what your module renders.
Licence
GNU General Public License v3.0 or later. See LICENSE. You may license your own module as you wish if it contains no code from this template; most of it does, so GPL-3.0-or-later is the simplest choice.