Installation
composer require dbp/relay-esign-bundle
php artisan vendor:publish --provider="DigitalBlueprint\RelayEsignBundle\RelayEsignBundle" --tag="config"
Configure Providers
Edit config/relay_esign.php to define your PDF-AS and MOA-SSP server endpoints under providers. Example:
'providers' => [
'pdfas' => [
'url' => 'https://pdfas.example.com',
'username' => env('PDFAS_USERNAME'),
'password' => env('PDFAS_PASSWORD'),
],
'moa_ssp' => [
'url' => 'https://moa-ssp.example.com',
'client_id' => env('MOA_CLIENT_ID'),
'client_secret' => env('MOA_CLIENT_SECRET'),
],
],
First Use Case: Sign a PDF
use DigitalBlueprint\RelayEsignBundle\Service\SignatureService;
$signatureService = app(SignatureService::class);
$result = $signatureService->signPdf(
file_get_contents('path/to/document.pdf'),
'recipient@example.com',
'pdfas' // Provider key
);
file_put_contents('signed.pdf', $result['pdf']);
Verify a Signature
$isValid = $signatureService->verifyPdfSignature('signed.pdf');
SignatureService class is the primary entry point for most operations.PDF Signing Workflow
$signatureService->signPdf(
$documentBase64,
$recipientEmail,
$providerKey,
['reason' => 'Contract approval', 'location' => 'Vienna']
);
Batch Processing Use Laravel queues to offload signing tasks:
SignPdfJob::dispatch($documentPath, $recipient, $providerKey)
->onQueue('esign');
Signature Verification
$verification = $signatureService->verifyPdfSignature($filePath);
// $verification includes: isValid, signer, timestamp, etc.
Laravel Storage: Integrate with Laravel’s filesystem for document storage:
use Illuminate\Support\Facades\Storage;
$document = Storage::disk('s3')->get('contracts/agreement.pdf');
$signed = $signatureService->signPdf($document, 'user@example.com', 'pdfas');
Storage::disk('s3')->put('contracts/signed_agreement.pdf', $signed['pdf']);
Event Dispatching: Trigger events for pre/post-signing actions:
event(new PdfSigningStarted($documentId, $recipient));
$result = $signatureService->signPdf(...);
event(new PdfSigned($result, $documentId));
Fallback Providers: Configure multiple providers and implement a fallback strategy:
try {
return $signatureService->signPdf($doc, $email, 'pdfas');
} catch (ProviderException $e) {
return $signatureService->signPdf($doc, $email, 'moa_ssp');
}
Frontend Integration: Use the ESign Frontend App for UI components or expose a Laravel API endpoint:
Route::post('/api/sign', [SignatureController::class, 'sign']);
| Use Case | Implementation Pattern |
|---|---|
| User uploads document | Use Laravel’s Request to handle file uploads. |
| Admin verifies signatures | Create a VerifySignature command or API. |
| Audit logging | Log signature events to a database table. |
| Multi-step signing workflow | Use Laravel’s stateful jobs or sessions. |
Provider-Specific Errors
try {
$result = $signatureService->signPdf(...);
} catch (PdfAsException $e) {
Log::error('PDF-AS Error: ' . $e->getMessage());
// Handle or rethrow
}
PDF Size Limits
if ($request->file('document')->getSize() > 50 * 1024 * 1024) {
throw new \Exception('File too large');
}
Caching Configuration
php artisan config:clear
Timeouts
max_execution_time or use queues.Character Encoding
debug: true in config/relay_esign.php for verbose logs.$signatureService->setLogger(app(\Monolog\Logger::class)->withName('esign_debug'));
Environment Variables
.env for sensitive data (e.g., PDFAS_USERNAME). The bundle does not auto-load these by default.Default Provider
SSL Verification
'providers' => [
'pdfas' => [
'verify_ssl' => env('PDFAS_VERIFY_SSL', true),
],
],
Custom Providers
Extend the DigitalBlueprint\RelayEsignBundle\Provider\AbstractProvider class to support additional signing services.
Signature Metadata
Override the SignatureService to add custom metadata to signatures:
$signatureService->extendMetadata(function ($metadata) {
$metadata['custom_field'] = auth()->id();
return $metadata;
});
Webhook Integration
Implement a WebhookListener to handle provider callbacks (e.g., for signing completion events).
Testing Use the bundle’s test utilities to mock providers:
$mockProvider = new MockPdfAsProvider();
$this->app->instance('pdfas_provider', $mockProvider);
How can I help you explore Laravel packages today?