PHP code example of optimus / pdf-bot

1. Go to this page and download the library: Download optimus/pdf-bot 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/ */

    

optimus / pdf-bot example snippets


// ... other service providers
Optimus\PdfBot\PdfBotServiceProvider::class,



namespace Infrastructure\Webhooks\Controllers;

use Illuminate\Http\Request;
use Optimus\PdfBot\PdfBotController;

class PdfController extends PdfBotController
{
    protected function onPdfReceived(array $data, Request $request)
    {
        // Do stuff with PDF
    }
}


$router->post('/webhooks/pdf', '\Infrastructure\Webhooks\Controllers\PdfController@receive');



return [
    'secret' => 'secret-used-for-generating-signature',

    'server' => 'http://url-to-pdf-bot-server',

    'header-namespace' => 'X-PDF-'
];

$pdfBot = app()->make(\Optimus\PdfBot\PdfBot::class);
$pdfBot->push('https://invoices.traede.com/1', [
    'type' => 'invoice',
    'id' => 1
]);



namespace Infrastructure\Webhooks\Controllers;

use Illuminate\Http\Request;
use Optimus\PdfBot\PdfBotController;

class PdfController extends PdfBotController
{
    protected function onPdfReceived(array $data, Request $request)
    {
        $meta = $data['meta'];
        $s3 = $data['s3'];

        switch ($meta['type']) {
            case 'invoice':
                $invoice = \Invoice::find($meta['id']);
                $invoice->pdf = $s3['path']['key'];
                $invoice->save();
                break;
        }
    }
}
bash
php artisan vendor:publish provider="Optimus\PdfBot\PdfBotServiceProvider"