wt-shared-libs is the shared PHP library behind the modules_v4 custom modules LinkEnhancer and Cronjob. It exists to keep two webtrees major versions (2.2 and 2.3) working side by side: version-dependent classes, methods and signatures are wrapped once here instead of duplicated in every module.
Parts and especially the loading routine are inspired by the similar package Jefferson49/webtrees-common.
What’s inside
Everything lives under the PSR-4 root Schwendinger\Webtrees\. The full per-method API is documented in the repository — this page is just an overview:
| Component | Namespace | What it does |
|---|---|---|
Functions.php | Helpers | 15 version-aware static helpers — version checks, routes, private data, DataTables normalization, HTTP status codes |
ClassName.php | Helpers | version-safe webtrees class names — get / isInstanceOf + 2.2/2.3 constants |
MoreI18N.php | Helpers | translation — translate for own strings, xlate for strings already covered by the webtrees core |
CliBootstrap.php | Services | CLI bootstrap — boot / guard + offline detection |
ModuleLog.php | Services | per-module singleton logger — error / debug / trace |
ModuleCustomTrait.php | Traits | custom-module metadata — author, version, URLs, customTranslations |
autoload.php | – | the loader (see below) |
Full per-method API:
reference.mdin the repository.
How the loader works
autoload.php
is a skew-tolerant loader: it compares the library version a module bundles with the version installed at the webtrees root and always lets the latest copy win, so a stale bundled copy can never shadow a newer site-level one. One rule for consumers — do not load the library from your module class’s __construct(); it can change the autoload order. The full premises and the proof live in reference.md
.
Quick start (as a consuming module)
Add a path repository to your module’s composer.json and register the loader in your own load routine (after your other composer libraries):
"repositories": [
{ "type": "path", "url": "../wt-shared-libs", "options": { "symlink": false } }
],
"require": {
"bschwede/wt-shared-libs": "^1.0"
},
"config": {
"prepend-autoloader": false
}
Releases
Releases are versioned by Git tag, and the tag always equals the composer.json version field (no v prefix). See CHANGELOG.md
.
Further reading
- API reference —
reference.md - Contributing / adding a class —
contributing.md - Changelog —
CHANGELOG.md - Issues & PRs on Codeberg