PHP code example of oxhq / pliego-php

1. Go to this page and download the library: Download oxhq/pliego-php 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/ */

    

oxhq / pliego-php example snippets


use Pliego\Php\DocumentEngine;
use Pliego\Php\InputAsset;
use Pliego\Php\RenderOptions;

$engine = new DocumentEngine(
    command: ['/opt/pliego/bin/pliego'],
    workDirectory: '/var/lib/my-app/pliego',
);

$result = $engine->render(
    html: '<!doctype html><link rel="stylesheet" href="assets/invoice.css"><h1>Invoice</h1>',
    options: new RenderOptions(locale: 'en-US', timezone: 'UTC'),
    assets: [
        new InputAsset(
            path: 'assets/invoice.css',
            sourcePath: '/srv/my-app/resources/invoice.css',
            mediaType: 'text/css;charset=utf-8',
        ),
    ],
);

file_put_contents('/srv/my-app/storage/invoice.pdf', $result->bytes());
sh
composer