This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

wt-shared-libs

Shared PHP library for the webtrees custom modules

    License: GPL v3 webtrees major version

    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:

    ComponentNamespaceWhat it does
    Functions.phpHelpers15 version-aware static helpers — version checks, routes, private data, DataTables normalization, HTTP status codes
    ClassName.phpHelpersversion-safe webtrees class names — get / isInstanceOf + 2.2/2.3 constants
    MoreI18N.phpHelperstranslation — translate for own strings, xlate for strings already covered by the webtrees core
    CliBootstrap.phpServicesCLI bootstrap — boot / guard + offline detection
    ModuleLog.phpServicesper-module singleton logger — error / debug / trace
    ModuleCustomTrait.phpTraitscustom-module metadata — author, version, URLs, customTranslations
    autoload.php–the loader (see below)

    Full per-method API: reference.md in 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