-
Notifications
You must be signed in to change notification settings - Fork 56
💥 Is your project not Laravel Lumen?
Lucas Nepomuceno edited this page Jul 29, 2021
·
2 revisions
Because the project is not Laravel/Lumen, the use of upload, download and encryption features is not documented.
Find functionality by implementing the framework's service containers or create your own solution.
If you want to use this package in a project that is not based on Laravel / Lumen, you need to make the adjustments below
composer require illuminate/container illuminate/filesystem ramsey/uuid
<?php
require_once 'vendor/autoload.php';
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Facade;
try {
$app = new Container();
$app->singleton('app', Container::class);
$app->singleton('files', Filesystem::class);
Facade::setFacadeApplication($app);
// Allow the use of Facades, only if necessary
// $app->withFacades();
} catch (\Throwable $th) {
// TODO necessary
}
<?php
require_once 'vendor/autoload.php';
use Illuminate\Container\Container;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Facade;
use LSNepomuceno\LaravelA1PdfSign\ManageCert;
try {
$app = new Container();
$app->singleton('app', Container::class);
$app->singleton('files', fn () => new Filesystem);
Facade::setFacadeApplication($app);
$cert = new ManageCert;
$cert->fromPfx('path/to/certificate.pfx', 'password');
$pdf = new SignaturePdf('path/to/pdf/file.pdf', $cert, SignaturePdf::MODE_RESOURCE) // Use resource mode is default
$resource = $pdf->signature();
} catch (\Throwable $th) {
// TODO necessary
}