psbits / scanner
Reusable scanner API and frontend component for barcode scanning
Package info
github.com/phantasie-schmiede/scanner
Type:typo3-cms-extension
pkg:composer/psbits/scanner
Requires
- php: ^8.3
- ext-mbstring: *
- typo3/cms-core: ^13.4 || ^14.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^11
- psbits/qa: @dev
- roave/security-advisories: dev-latest
- saschaegerer/phpstan-typo3: ^2.1 || ^3.0
- typo3/testing-framework: ^9.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-22 13:39:54 UTC
README
Reusable camera- and file-based barcode scanning for other extensions. The intended use cases are media archiving (books, DVDs, CDs) and household management (recording purchases).
Requirements
- TYPO3:
13.4or14.3 - PHP:
8.3or newer - Live camera scanning requires a secure context (HTTPS or localhost)
- Browser:
getUserMediafor live camera scanning. The nativeBarcodeDetectoris used where available; the fallback decodes with the vendored zxing-wasm reader (about 1 MB wasm binary, loaded on first use)
Installation
composer require psbits/scanner
Integration
-
Add the scanner partials to your view configuration:
plugin.tx_<your_extension> { view { partialRootPaths.20 = EXT:scanner/Resources/Private/Partials } } -
Render the partial in a Fluid template:
<f:render partial="Scanner" />
-
Listen to the scanner events on the root element (
data-psbits-scanner). Scan results are submitted to the API automatically unless disabled:document .querySelector('[data-psbits-scanner]') .addEventListener('psbits-scanner:scan', (event) => { // event.detail = { content, format, source, clientTimestamp, meta } });
Events emitted by the component:
psbits-scanner:readypsbits-scanner:capabilitiespsbits-scanner:permissionpsbits-scanner:scanpsbits-scanner:submittedpsbits-scanner:errorpsbits-scanner:stopped
API contract (v1)
All responses share this envelope:
{
"success": true,
"data": {},
"error": null
}
For errors:
{
"success": false,
"data": null,
"error": {
"code": "validation_failed",
"message": "...",
"details": {}
}
}
GET /scanner/api/v1/health
Health endpoint.
GET /scanner/api/v1/capabilities
Returns supported formats, modes and endpoint references.
POST /scanner/api/v1/result
Accepts scan results:
{
"content": "9780201379624",
"format": "ean_13",
"source": "camera",
"clientTimestamp": "2026-01-01T12:00:00+00:00",
"meta": {}
}
contentis required (1–1024 characters)formatis required and must be one of the supported formatssourceis eithercameraorimage(defaults tocamera)clientTimestampis optional, any date/time string the server can parsemetais optional, any JSON object
Supported formats:
ean_13ean_8upc_aupc_ecode_128code_39itfcodabar
Security and privacy
- Live camera mode only works in secure contexts (HTTPS/localhost).
- The frontend checks browser support and permission state and emits explicit events.
- The backend validates incoming result payloads and does not persist scan contents by default.
Development
composer install composer qa
composer qa fixes everything that can be fixed automatically and afterwards runs all linters and the static
analysis. The same checks run in the CI GitHub Actions workflow and in the pre-commit hook that is
installed by composer install.
The workflow also runs a support matrix that checks the supported TYPO3 and PHP combinations still resolve their
dependencies, and publishes the extension to TER when a semver tag is pushed. Publishing requires the
TYPO3_API_TOKEN repository secret.