1. Go to this page and download the library: Download marzsv/sv-dte-signer 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/ */
use Marzsv\DteSigner\DteSigner;
$signer = new DteSigner();
// Sign from a JSON file
$response = $signer->sign('/path/to/dte_request.json');
if ($response['success']) {
echo "DTE signed successfully from file!\\n";
}
use Marzsv\DteSigner\DteSigner;
// Use a custom certificate directory
$signer = new DteSigner('/path/to/certificates');
$response = $signer->sign($request);
use Marzsv\DteSigner\DteVerifier;
// Initialize the verifier
$verifier = new DteVerifier();
// Verify signature and extract original DTE content
$response = $verifier->verify($jwsToken, '12345678901234');
if ($response['success']) {
echo "DTE signature verified successfully!\n";
echo "Original DTE data:\n";
print_r($response['data']);
} else {
echo "Verification failed: " . $response['message'] . "\n";
}
use Marzsv\DteSigner\DteVerifier;
$verifier = new DteVerifier();
// Extract payload without signature verification (NOT RECOMMENDED for production)
$response = $verifier->extractPayload($jwsToken);
if ($response['success']) {
echo "Payload extracted (signature not verified):\n";
print_r($response['data']);
}
use Marzsv\DteSigner\DteVerifier;
// Use custom certificate directory for verification
$verifier = new DteVerifier('/path/to/certificates');
$response = $verifier->verify($jwsToken, $nit);
public function __construct(string $certificateDirectory = 'certificates')
public function sign(array|string $input): array
public function __construct(string $certificateDirectory = 'certificates')
public function verify(string $jwsToken, string $nit): array
public function extractPayload(string $jwsToken): array