Installation:
composer require dbp/relay-verity-bundle
Ensure DbpRelayVerityBundle is registered before DbpRelayCoreBundle in config/bundles.php.
Basic Configuration:
Create config/packages/dbp_relay_verity.yaml with a minimal backend (e.g., PDF/A validation):
dbp_relay_verity:
backends:
pdfa:
validator: 'Dbp\Relay\VerapdfBundle\Service\PDFAValidationAPI'
profiles:
default:
name: 'PDF/A Validation'
rule: 'pdfa.validity == true'
checks:
pdfa:
backend: 'pdfa'
config: '{"flavour": "1b"}'
First Use Case:
Trigger validation via the Relay API endpoint (e.g., /api/verity/validate). Example payload:
{
"profile": "default",
"file": "/path/to/document.pdf"
}
Profile-Driven Validation:
Define reusable validation profiles in config/packages/dbp_relay_verity.yaml to group checks (e.g., archive, accessibility). Example:
profiles:
archive:
rule: 'pdfa.validity == true && pdfa_b2.validity == true'
checks:
pdfa: { backend: 'pdfa', config: '{"flavour": "1b"}' }
pdfa_b2: { backend: 'pdfa', config: '{"flavour": "b2"}' }
Backend Integration:
Extend validation backends by implementing Dbp\Relay\VerityBundle\Service\ValidationAPIInterface. Register new backends in the config:
backends:
custom:
validator: 'App\Service\CustomValidator'
API Endpoint Usage:
/api/verity/validate with:
{ "profile": "archive", "file": "base64_encoded_file" }
{
"success": true,
"results": {
"pdfa": { "validity": true, "details": [...] }
}
}
File Handling:
DbpRelayVerityBundle's file_handler service).Dbp\Relay\VerityBundle\Service\FileHandlerInterface).Dbp\Relay\VerityBundle\Message\ValidateFile messages.verity.post_validate events to process results (e.g., log, notify).Symfony\Contracts\Cache\CacheInterface).Bundle Order:
DbpRelayVerityBundle must load before DbpRelayCoreBundle. Misordering causes ServiceNotFoundException.config/bundles.php order and run php bin/console cache:clear.Backend Service Names:
validator key in backends (e.g., typo in FQCN) throws ServiceNotFoundException.Dbp\Relay\VerapdfBundle\Service\PDFAValidationAPI).File Size Limits:
post_max_size or memory limits.upload_max_filesize and use streaming (implement FileHandlerInterface).Rule Syntax:
rule syntax (e.g., pdfa.validity = true without ==) fails silently.==) and validate rules with php bin/console debug:container dbp_relay_verity.rule_parser.APP_ENV=dev) and check var/log/dev.log for validation errors.use Symfony\Component\VarDumper\VarDumper;
VarDumper::dump($validator->validate($file, $profile));
Custom Validators:
ValidationAPIInterface and register in services.yaml:
services:
App\Service\CustomValidator:
tags: ['dbp_relay_verity.backend']
Profile Dynamic Loading:
Dbp\Relay\VerityBundle\Loader\ProfileLoaderInterface to load profiles from a database.Result Transformation:
Dbp\Relay\VerityBundle\Result\ValidationResult to add custom metadata.VerapdfBundle) require additional services (e.g., HTTP clients). Configure them in services.yaml.extends in profiles to reuse checks:
profiles:
extended_archive:
extends: archive
checks:
additional:
backend: 'custom'
How can I help you explore Laravel packages today?