PHPackages                             dvsa/mot-document-module - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dvsa/mot-document-module

ActiveLibrary

dvsa/mot-document-module
========================

Shared Document and Report Generation Module

v3.0.0(1y ago)012.5k↓50%1PHPPHP ^8.2CI passing

Since Jun 9Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/dvsa/mot-document-module)[ Packagist](https://packagist.org/packages/dvsa/mot-document-module)[ RSS](/packages/dvsa-mot-document-module/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (13)Versions (13)Used By (0)

Document snapshot and report generation library
===============================================

[](#document-snapshot-and-report-generation-library)

This library provides two modules; one to create point-in-time snapshots of documents and another to generate a report based on a given template and document identifier. These modules enforce clean if slightly awkward separation of concerns; the document creation module requires a database connection while the report service directly invokes lambda Certificate Generation Service via its RESTful API.

Modules
-------

[](#modules)

- DvsaDocument
- DvsaReport

Installation
------------

[](#installation)

Add the git repository to the `repositories` section of your application's `composer.json`:

```
"repositories": [
    {
        "type": "git",
        "url": "ssh://git@gitlab.clb.npm/sc/dvsa-document-module.git"
    }
]

```

Then simply `require` the relevant [tag](http://gitlab.clb.npm/sc/dvs-document-module/tags):

```
"require": {
    "dvsa/dvsa-document-module": "0.1.0"
}

```

Configuration
-------------

[](#configuration)

### Document Module

[](#document-module)

The document module does not require any standalone configuration, although it does depend on doctrine and a database connection being available to the consumer application.

### Report Module

[](#report-module)

If you need to generate a report, ensure the following keys are present somewhere in your application's configuration (i.e. somewhere under config/autoload or similar):

```
'certificate_generation' => [
        'uri' => {lambda_uri},
        'x-api-key' => {labda_api_key},
        'logCalls' => {true or false value}
]

```

Usage
-----

[](#usage)

### Creating a document (DvsaDocument)

[](#creating-a-document-dvsadocument)

The document module does not expose a route to create a new document since this logic will most often be encompassed as part of an application specific call. The `DocumentService` exposes a method to do this directly:

```
public function createSnapshot($templateName, $data = [])

```

`templateName` must be a valid 'friendly name' as defined by the consuming application; this will be looked up against a list of database templates and stored as a foreign key against the newly created document.

`data` is simply an array of key/value pairs which make up the document's content.

### Return value

[](#return-value)

The return value will **always** be a document identifier; if the process fails an `EmptyDocumentException` or `TemplateNotFoundException` will be raised.

### Retrieving the report name for a document (DvsaDocument)

[](#retrieving-the-report-name-for-a-document-dvsadocument)

The document module exposes a route to look up the relevant jasper report name for a given document identifier and optional variation, which in turn invokes the following `DocumentService` method:

```
public function getReportName($documentId, $variation = null)

```

The optional `variation` parameter must correspond to a valid template variation defined in the application's database. This allows for one document to be used as the source data for multiple reports whilst still enforcing that the reports are somehow related; i.e. the same report translated into a different language.

### Return value

[](#return-value-1)

The return value will **always** be a string representing the full Jasper Report name. If the process fails a `TemplateNotFound` exception will be raised.

### Route

[](#route)

The above service call is exposed via a single route, `/get-report-name/:id/:variation` which if successful will return a JSON object with a single property, `report-name`.

Retrieving a report (DvsaReport)
--------------------------------

[](#retrieving-a-report-dvsareport)

Armed with a `$documentId` and a `$reportName`, simply get an instance of the `ReportService` and invoke the following method:

```
public function getReportById($documentId, $reportName, $runtimeParams = [])

```

This method constructs a URL which is then requested directly via Jasper Server's RESTful API; as such the consuming application in this instance must be able to communicate directly with your configured Jasper endpoint.

The optional `runtimeParams` variable will be passed along with the request allowing your template to accept extra input at report generation time. Each key of the array will be available within your report as $P{KeyName} which will have its value replaced accordingly.

### Return value

[](#return-value-2)

This method will return a raw \\Laminas\\Http\\Response which you can interrogate for the relevant document information (size, content type, etc). The response also stores an over-arching success status, `$response->isSuccess()`.

### Converting a report response into a domain model (DvsaReport)

[](#converting-a-report-response-into-a-domain-model-dvsareport)

If the Zend Http Response object isn't suitable, you may inject it into back into a helper method of the service which will translate it into a Report model:

```
public function getReportFromResponse(\Laminas\Http\Response $response)

```

### Return value

[](#return-value-3)

This will return a Report model which is simply a business layer representation of the original response. It will throw a ReportNotFoundException if the response was not successful.

Contributing
------------

[](#contributing)

Please refer to our [Contribution Guide](/CONTRIBUTING.md).

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance65

Regular maintenance activity

Popularity26

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~132 days

Total

4

Last Release

677d ago

Major Versions

v1.0.1 → v2.0.02023-09-19

v2.0.0 → v3.0.02024-07-10

PHP version history (3 changes)v1.0.0PHP ^8.0

v2.0.0PHP 8.1

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ac141ec696a70dbc4b8c1c7541cd1bfc06e99617f2484d7631ed43cb48d2f6b?d=identicon)[dvsa](/maintainers/dvsa)

---

Top Contributors

[![jenniferchoo](https://avatars.githubusercontent.com/u/184102919?v=4)](https://github.com/jenniferchoo "jenniferchoo (6 commits)")[![ccurran01](https://avatars.githubusercontent.com/u/32199652?v=4)](https://github.com/ccurran01 "ccurran01 (2 commits)")[![jennifer-choo](https://avatars.githubusercontent.com/u/113026728?v=4)](https://github.com/jennifer-choo "jennifer-choo (2 commits)")[![aaronlong](https://avatars.githubusercontent.com/u/5321346?v=4)](https://github.com/aaronlong "aaronlong (1 commits)")[![LMBishop-kainos](https://avatars.githubusercontent.com/u/146719064?v=4)](https://github.com/LMBishop-kainos "LMBishop-kainos (1 commits)")[![mateuszc-kainos](https://avatars.githubusercontent.com/u/20680998?v=4)](https://github.com/mateuszc-kainos "mateuszc-kainos (1 commits)")[![sdh100shaun](https://avatars.githubusercontent.com/u/79883?v=4)](https://github.com/sdh100shaun "sdh100shaun (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dvsa-mot-document-module/health.svg)

```
[![Health](https://phpackages.com/badges/dvsa-mot-document-module/health.svg)](https://phpackages.com/packages/dvsa-mot-document-module)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[saeven/zf3-circlical-user

Complete user entity, rights, and access module for Laminas

3718.7k](/packages/saeven-zf3-circlical-user)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
