Developer Guide

How to Sign PDFs with PHP

To sign a PDF with PHP: Install the TurboDocx SDK (composer require turbodocx/sdk), configure your API key, and call TurboSign::sendSignature() with your document and recipient details.

This guide shows you how to integrate e-signatures into your Laravel or Symfony application in under 5 minutes.

5 min

Setup time

PHP

PHP 8.1+

Modern enums

Type-Safe

Typed classes

1

Installation

Install the TurboDocx SDK via Composer. The package uses modern PHP 8.1+ features including enums and typed properties.

Composer
composer require turbodocx/sdk

Requirements: PHP 8.1+, Composer, ext-json, ext-fileinfo. Compatible with Laravel, Symfony, and vanilla PHP.

2

Obtaining an API Key

Before you begin, you'll need your API credentials from the TurboDocx dashboard.

  1. Sign up for a free account at TurboDocx
  2. Navigate to Settings → API Keys
  3. Copy your API Key and Organization ID
.env
TURBODOCX_API_KEY=your_api_key_here
TURBODOCX_ORG_ID=your_org_id_here
TURBODOCX_SENDER_EMAIL=you@company.com
TURBODOCX_SENDER_NAME=Your Company Name
3

Sending a Signing Request

Use the SDK to send a document for signature. The recipient will receive an email with a link to sign.

SendSignature.php
<?php

use TurboDocx\TurboSign;
use TurboDocx\Config\HttpClientConfig;
use TurboDocx\Types\Recipient;
use TurboDocx\Types\Field;
use TurboDocx\Types\SignatureFieldType;
use TurboDocx\Types\TemplateConfig;
use TurboDocx\Types\FieldPlacement;
use TurboDocx\Types\Requests\SendSignatureRequest;

// Configure with your API credentials
TurboSign::configure(new HttpClientConfig(
    apiKey: $_ENV['TURBODOCX_API_KEY'],
    orgId: $_ENV['TURBODOCX_ORG_ID'],
    senderEmail: $_ENV['TURBODOCX_SENDER_EMAIL'],  // REQUIRED
    senderName: $_ENV['TURBODOCX_SENDER_NAME']     // Recommended
));

// Send document for signature
$result = TurboSign::sendSignature(
    new SendSignatureRequest(
        recipients: [
            new Recipient('John Doe', 'john@example.com', 1)
        ],
        fields: [
            new Field(
                type: SignatureFieldType::SIGNATURE,
                recipientEmail: 'john@example.com',
                template: new TemplateConfig(
                    anchor: '{signature1}',
                    placement: FieldPlacement::REPLACE,
                    size: ['width' => 100, 'height' => 30]
                )
            )
        ],
        file: file_get_contents('contract.pdf'),
        documentName: 'Partnership Agreement'
    )
);

echo "Document ID: {$result->documentId}\n";

Modern PHP: Uses PHP 8.1+ features like enums (SignatureFieldType::SIGNATURE) and named parameters for type safety.

4

Processing Results with Webhooks

Configure webhooks to receive real-time notifications when documents are signed.

WebhookController.php (Laravel)
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use TurboDocx\TurboSign;

class WebhookController extends Controller
{
    public function handle(Request $request)
    {
        $eventType = $request->input('event_type');
        $data = $request->input('data');

        if ($eventType === 'document.completed') {
            $documentId = $data['documentId'];

            // Download the signed PDF
            $signedPdf = TurboSign::download($documentId);

            // Save to storage
            Storage::put("signed/{$documentId}.pdf", $signedPdf);
        }

        return response()->json(['received' => true]);
    }
}
5

Conclusion

You now have everything you need to integrate document signing into your PHP application. The TurboDocx SDK handles authentication, document delivery, signature collection, and provides legally-binding audit trails.

What you can do next:

  • Add multiple recipients with sequential signing order
  • Use different field types: initials, dates, text, checkboxes
  • Integrate with Laravel Queues for async processing
  • Get audit trails and compliance certificates

Related Guides

Resources

Frequently Asked Questions

How do I sign a PDF with PHP?

Install the TurboDocx SDK (composer require turbodocx/sdk), configure it with your API key, then use TurboSign::sendSignature() to send the document for e-signature.

Does the PHP SDK work with Laravel?

Yes, the TurboDocx PHP SDK works with Laravel, Symfony, and any PHP 8.1+ application. It uses typed classes and enums for full IDE support.

What PHP version is required?

The TurboDocx PHP SDK requires PHP 8.1 or higher.

Ready to Get Started?

Create a free account and get your API key. Start sending documents for signature in minutes.