Lumina Lighting Design Suite
Projects New design Fixtures Criteria Reference Docs Sign in Create an account

Plugin architecture

Plugins let an organisation extend the application without modifying it: vetted standards data, a local energy model, extra report sections, new exporters.

Structure

A plugin is a directory under plugins/ containing plugin.php which returns a definition array:


<?php
return [
    'name'    => 'ASHRAE 90.1 power density limits',
    'version' => '1.0',
    'enabled' => true,
    'hooks'   => [
        'standards.criteria' => function (App\Standards\Criteria $criteria, array $row) {
            if ($criteria->category === 'Office') {
                $criteria->lpdLimit = 6.6;   // W/m2 from the governing code
            }
            return $criteria;
        },
    ],
];

Plugins are discovered at boot. Classes under plugins/ autoload from the Plugin\ namespace, so plugins/ashrae/src/Provider.php declaring Plugin\ashrae\src\Provider is found automatically.

A hook that throws is logged and skipped. One broken plugin cannot take the application down.

Hooks

Every hook is a filter: it receives the current value plus context and returns the value, modified or not.

| Hook | Receives | Purpose | | --- | --- | --- | | standards.criteria | Criteria $criteria, array $row | Override or extend the criteria for a space type | | standards.compliance | array $result, array $results, Criteria $criteria | Add checks, or adjust verdicts | | analysis.results | array $results, array $scene | Add computed quantities to the result set | | report.sections | ReportBuilder $builder, array $results | Append pages to the PDF report |

Adding a compliance check


'standards.compliance' => function (array $result, array $results, $criteria): array {
    $lpd = $results['power']['lpd_w_per_m2'] ?? null;
    $area = $results['room']['area'] ?? 0;

    // A local rule: small rooms get a relaxed allowance.
    $limit = $area < 20 ? 9.0 : 6.5;

    $result['checks'][] = [
        'id'        => 'local_lpd',
        'label'     => 'Power density, local amendment',
        'status'    => $lpd === null ? 'not-assessed' : ($lpd <= $limit ? 'pass' : 'fail'),
        'actual'    => $lpd,
        'required'  => $limit,
        'unit'      => 'W/m2',
        'delta'     => $lpd === null ? null : round($limit - $lpd, 3),
        'delta_pct' => $lpd === null ? null : round(100 * ($limit - $lpd) / $limit, 1),
        'direction' => 'max',
        'reference' => 'Local amendment 2026',
        'note'      => 'Relaxed allowance below 20 square metres.',
    ];
    return $result;
},

Recompute the summary if you add checks and need the counts to match. The verdict is derived from summary.failed, so returning a consistent summary keeps the cover page honest.

Adding computed quantities


'analysis.results' => function (array $results, array $scene): array {
    // Illuminance per watt per square metre, a useful design efficiency metric.
    $avg  = $results['statistics']['task_area']['avg'] ?? null;
    $lpd  = $results['power']['lpd_w_per_m2'] ?? null;
    if ($avg !== null && $lpd) {
        $results['custom']['lux_per_lpd'] = round($avg / $lpd, 1);
    }
    return $results;
},

The scene argument carries the Room, the Luminaire array, the windows, control zones, the schedule and the climate, so a plugin can run its own calculation against the same objects the engine used.

Appending report pages


'report.sections' => function ($builder, array $results) {
    $pdf = $builder->writer();
    $pdf->addPage();
    $pdf->text(16, 20, 'Local authority submission data', 14, 'HB', [31, 59, 99]);
    $pdf->paragraph(16, 32, 178,
        'Reference: ' . ($results['project']['reference'] ?? ''), 9);
    return $builder;
},

Reference data instead of code

Much of what a plugin might do is achievable by editing data. The standards, space types, tariffs, emission factors and locations all live in database/seeds/ as plain PHP arrays. Editing those and re-running php bin/seed.php updates the reference data in place, keyed on natural identifiers so existing projects keep working.

Use a plugin when the behaviour is conditional. Use the seed data when the values are simply different.

Guidance

  • Hooks run on every calculation, so keep them cheap. Anything expensive belongs behind a cache.
  • Return the value you were given when you do not want to change it. Returning null discards it.
  • Do not mutate the scene objects: they are shared with the engine for the current run.
  • Version your plugin and record where its data came from. Someone will need to defend those numbers.