1. Go to this page and download the library: Download clonixdev/sri-sender 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/ */
clonixdev / sri-sender example snippets
use DazzaDev\SriSender\Sender;
// Instanciar el sender
$sender = new Sender(test: true); // Usar entorno de pruebas (test: true)
// XML como string
$xmlContent = file_get_contents(__DIR__ . '/factura.xml');
// Enviar XML a recepción
$validationResult = $sender->validate($xmlContent);
// Enviar XML a autorización
$accessKey = 'clave_acceso_del_documento';
$authorizationResult = $sender->authorize($accessKey);
// Enviar XML a recepción y autorización en un solo paso
$result = $sender->send($accessKey, $xmlContent);
if ($result['success']) {
echo "Validación y autorización exitosas!";
echo "Status: " . $result['status'];
} else {
echo "Validación y/o autorización fallidas: " . $result['error'];
}
use DazzaDev\SriSender\Sender;
use DazzaDev\SriSender\Config\SriConfig;
// Configuración personalizada
$config = new SriConfig(
soapOptions: [
'connection_timeout' => 300,
'default_socket_timeout' => 300,
'user_agent' => 'My Custom Agent'
],
retryConfig: [
'maxAttempts' => 3,
'delaySeconds' => 2
]
);
// Instanciar el sender con la configuración personalizada
$sender = new Sender(test: false, $config);
// Validar XML
try {
$result = $sender->validate($xmlContent);
if ($result['success']) {
echo "Validación exitosa!";
echo "Status: " . $result['status'];
} else {
echo "Validación fallida: " . $result['error'];
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.