PHP code example of helori / php-sign

1. Go to this page and download the library: Download helori/php-sign library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

helori / php-sign example snippets


use Helori\PhpSign\Elements\Document;
use Helori\PhpSign\Elements\Signer;
use Helori\PhpSign\Elements\Signature;
use Helori\PhpSign\Elements\Scenario;
use Helori\PhpSign\Elements\Requester;
use Helori\PhpSign\Elements\Transaction;

$document = new Document();
$document->setId(1);
$document->setName('Document #1');
$document->setFilepath('/document/1/absolute/path');

$signer = new Signer();
$signer->setId(1);
$signer->setFirstname('John');
$signer->setLastname('Doe');
$signer->setEmail('[email protected]');
$signer->setPhone('+33611223344');

$signature = new Signature();
$signature->setDocumentId(1);
$signature->setSignerId(1);
$signature->setLabel('Your signature');
$signature->setPage(1);
$signature->setX(100);
$signature->setY(200);
$signature->setWidth(150);
$signature->setHeight(80);

$scenario = new Scenario();
$scenario->setSigners([$signer]);
$scenario->setDocuments([$document]);
$scenario->setSignatures([$signature]);

// You may use your own signature service configuration here :
$driverName = 'yousign'; // 'universign', 'docusign', ...
$driverConfig = [
    // mode : can be 'production' for production mode, or another (free) value for testing mode
    'mode' => 'production',
    'api_key' => 'your_yousign_secret_api_key',
];

$requester = new Requester($driverName, $driverConfig);
$transaction = $requester->createTransaction($scenario);

$requester = new Requester($driverName, $driverConfig);
$transaction = $requester->getTransaction($transactionId);

$scenario->setStatusUrl('https://your-app.com/your-sign-webhook-uri');

use Helori\PhpSign\Elements\Webhook;

// Automatically populated with the current request params
$webhook = new Webhook();

// Get the transaction ID and status from the webhook to decide what you need to do.
$transactionId = $webhook->getTransactionId();
$transactionStatus = $webhook->getTransactionStatus();

$requester = new Requester($driverName, $driverConfig);
$documents = $requester->getDocuments($transactionId);

foreach($documents as $document){
    $content = $document->getContent();
    file_put_contents('/path/where/you/want/to/store/the/document.pdf', $document->getContent());
}
bash
composer