1. Go to this page and download the library: Download mitwork/kalkan 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/ */
namespace App\Controllers;
use \Mitwork\Kalkan\Services\KalkanSignatureService;
use \Mitwork\Kalkan\Services\KalkanValidationService;
class TestXmlController extends Controller
{
function __construct(
public KalkanSignatureService $signatureService,
public KalkanValidationService $validationService,
)
{
//
}
function testXmlSign(): string
{
$xml = '<?xml...';
$key = 'base64...';
$password = 'password';
$result = $this->signatureService->signXml($xml, $key, $password);
// dd($result);
// <?xml...
return $result;
}
function testXmlVerify(): bool
{
$signedXml = $this->testXmlSign();
$result = $this->validationService->verifyXml($signedXml);
// dd($result);
// true
return $result;
}
}
namespace App\Controllers;
use \Mitwork\Kalkan\Services\KalkanSignatureService;
use \Mitwork\Kalkan\Services\KalkanValidationService;
use \Mitwork\Kalkan\Services\KalkanExtractionService;
class TestCmsController extends Controller
{
function __construct(
public KalkanSignatureService $signatureService,
public KalkanValidationService $validationService,
public KalkanExtractionService $extractionService,
)
{
//
}
function testCmsSign(): string
{
$data = 'base64...';
$key = 'base64...';
$password = 'password';
$result = $this->signatureService->signCms($data, $key, $password);
// dd($result);
// base64...
return $result;
}
function testCmsVerify(): bool
{
$cms = 'base64...';
$data = 'base64...';
$result = $this->validationService->verifyCms($cms, $data);
// dd($result);
// true
return $result;
}
function testCmsExtract(): string
{
$cms = 'base64...';
$result = $this->extractionService->extractCms($cms);
// dd($result);
// base64...
return $result;
}
}
namespace App\Listeners;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;
use Mitwork\Kalkan\Events\DocumentSigned;
class DocumentEventsListener
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
public function onSigned(DocumentSigned $event): void
{
Log::info('Документ подписан', [
'id' => $event->id,
'result' => $event->result,
]);
}
}