PHP code example of slam / php-p7m-reader
1. Go to this page and download the library: Download slam/php-p7m-reader 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/ */
slam / php-p7m-reader example snippets
$p7mReader = \Slam\P7MReader\P7MReader::decodeFromFile(
new \SplFileObject('/path/to/my.xml.p7m'),
__DIR__ . '/tmp' // Optional custom temporary directory, defaults to sys_get_temp_dir()
);
// OR
$p7mReader = \Slam\P7MReader\P7MReader::decodeFromBase64(
'Abc==', // base64 encoded content file
__DIR__ . '/tmp' // Optional custom temporary directory, defaults to sys_get_temp_dir()
);
var_dump($p7mReader->getP7mFile()); // string: The original P7M file
var_dump($p7mReader->getContentFile()); // SplFileObject: The signed content
var_dump($p7mReader->getCertFile()); // SplFileObject: The certificate
var_dump($p7mReader->getCertData()); // array: Certificate data in openssl_x509_parse output format