PHP code example of nigel / utils

1. Go to this page and download the library: Download nigel/utils 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/ */

    

nigel / utils example snippets




use Nigel\Utils\Core\SSL\SSLGenerator;

omain = 'example.com';

$rootFolder = rtrim(__DIR__, '/') . '/files/';
$sslGenerator = new SSLGenerator($rootFolder);

$csrDetails = array(
    "countryName" => "ZW",
    "stateOrProvinceName" => "Harare",
    "localityName" => "Harare",
    "organizationName" => "Example Inc",
    "organizationalUnitName" => "IT Department",
    "commonName" => $domain,
    "emailAddress" => "admin@$domain",
);

try {
    $ssStrings = $sslGenerator->generateSSLStrings($domain, $csrDetails);
    echo "Private Key:\n\n" . $ssStrings['privateKey'] . "\n\n" .
        "CSR:\n\n" . $ssStrings['csr'] . "\n\n" .
        "Cert:\n\n" . $ssStrings['cert'];
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

// OR

try {
    $sslFiles = $sslGenerator->generateSSLFiles($domain, $csrDetails);
    echo $sslFiles;
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}



use Nigel\Utils\Core\Checksums\ContipayChecksum;

KEY HERE
-----END PRIVATE KEY-----
EOD;

$authKey = "NmZKTkdJdnVDJMWnJMQT";
$reference = "PAYOUT-83bbbe26-1cfa-435d";
$merchantId = $MERCHANT_ID;
$accountNumber = "0782000340";
$amount = "5.0";

$checksum = (new ContipayChecksum())->generateChecksum($authKey . $reference . $merchantId . $accountNumber . $amount, true, openssl_get_privatekey($privKey, ""));

echo $checksum;



use Nigel\Utils\Core\Phone\Phone;

;

$phone = "0782000340"; // Zimbabwe Econet Number

$test = (new Phone($phone, 'ZW'))->internationalFormat();


echo $test;