1. Go to this page and download the library: Download opa/opa-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/ */
opa / opa-php example snippets
use OPA\OpaArchive;
$archive = new OpaArchive('Summarize the attached report.');
$archive->getManifest()
->setTitle('Report Summary')
->setExecutionMode('batch');
$archive->addDataFromString('data/report.csv', $csvContent);
$archive->save('summary-task.opa');
use OPA\OpaReader;
$reader = OpaReader::open('summary-task.opa');
echo $reader->getManifest()->getTitle();
echo $reader->getPromptContent();
if ($reader->hasSessionHistory()) {
foreach ($reader->getSessionHistory()->getMessages() as $msg) {
echo "[{$msg->getRole()}] {$msg->getContent()}\n";
}
}
$reader->close();
use OPA\OpaArchive;
use OPA\Signer;
use OPA\Verifier;
// Sign on create
$signer = new Signer($privateKeyPem, $certificatePem);
$archive = new OpaArchive('Analyze the data.');
$archive->save('signed.opa', $signer);
// Verify
$result = Verifier::verify('signed.opa');
if ($result->isSigned() && $result->isValid()) {
echo "Signature verified.\n";
}
// Verify against a specific trusted certificate
$result = Verifier::verify('signed.opa', $trustedCertPem);
// Signer supports SHA-256 (default), SHA-384, SHA-512
// MD5 and SHA-1 are rejected per spec
$signer = new Signer($privateKeyPem, $certificatePem, 'SHA-256');
// Sign an existing archive in place
$signer->sign('archive.opa');
// Or sign during creation
$archive->save('archive.opa', $signer);
$result = Verifier::verify('archive.opa');
$result->isSigned(): bool; // whether signature files are present
$result->isValid(): bool; // whether all verification checks passed
$result->getError(): ?string; // error message if verification failed
bash
composer
bash
php examples/generate-hn-pirate-summary.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.