1. Go to this page and download the library: Download yourivw/leclient 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/ */
yourivw / leclient example snippets
ini_set('max_execution_time', 120); // Maximum execution time in seconds.
use LEClient\LEClient;
$client = new LEClient($email); // Initiating a basic LEClient with an array of string e-mail address(es).
$client = new LEClient($email, LEClient::LE_STAGING); // Initiating a LECLient and use the LetsEncrypt staging URL.
$client = new LEClient($email, LEClient::LE_PRODUCTION); // Initiating a LECLient and use the LetsEncrypt production URL.
$client = new LEClient($email, true); // Initiating a LECLient and use the LetsEncrypt staging URL.
$client = new LEClient($email, true, $logger); // Initiating a LEClient and use a PSR-3 logger (\Psr\Log\LoggerInterface).
$client = new LEClient($email, true, LEClient::LOG_STATUS); // Initiating a LEClient and log status messages (LOG_DEBUG for full debugging).
$client = new LEClient($email, true, LEClient::LOG_STATUS, 'keys/'); // Initiating a LEClient and select custom certificate keys directory (string or array)
$client = new LEClient($email, true, LEClient::LOG_STATUS, 'keys/', '__account/'); // Initiating a LEClient and select custom account keys directory (string or array)
$acct = $client->getAccount(); // Retrieves the LetsEncrypt Account instance created by the client.
$acct->updateAccount($email); // Updates the account with new contact information. Supply an array of string e-mail address(es).
$acct->changeAccountKeys(); // Generates a new RSA keypair for the account and updates the keys with LetsEncrypt.
$acct->deactivateAccount(); // Deactivates the account with LetsEncrypt.
$order = $client->getOrCreateOrder($basename, $domains); // Get or create order. The basename is preferably the top domain name. This will be the directory in which the keys are stored. Supply an array of string domain names to create a certificate for.
$order = $client->getOrCreateOrder($basename, $domains, $keyType); // Get or create order. keyType can be set to "ec" to get ECDSA certificate. "rsa-4096" is default value. Accepts ALGO-SIZE format.
$order = $client->getOrCreateOrder($basename, $domains, $keyType, $notBefore); // Get or create order. Supply a notBefore date as a string similar to 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss).
$order = $client->getOrCreateOrder($basename, $domains, $keyType, $notBefore, $notAfter); // Get or create order. Supply a notBefore and notAfter date as a string similar to 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss).
use LEClient\LEOrder;
$valid = $order->allAuthorizationsValid(); // Check whether all authorizations in this order instance are valid.
$pending = $order->getPendingAuthorizations($type); // Get an array of pending authorizations. Performing authorizations is described further on. Type is LEOrder::CHALLENGE_TYPE_HTTP or LEOrder::CHALLENGE_TYPE_DNS.
$verify = $order->verifyPendingOrderAuthorization($identifier, $type); // Verify a pending order. The identifier is a string domain name. Type is LEOrder::CHALLENGE_TYPE_HTTP or LEOrder::CHALLENGE_TYPE_DNS.
$deactivate = $order->deactivateOrderAuthorization($identifier); // Deactivate an authorization. The identifier is a string domain name.
$finalize = $order->finalizeOrder(); // Finalize the order and generate a Certificate Signing Request automatically.
$finalize = $order->finalizeOrder($csr); // Finalize the order with a custom Certificate Signing Request string.
$finalized = $order->isFinalized(); // Check whether the order is finalized.
$cert = $order->getCertificate(); // Retrieves the certificate and stores it in the keys directory.
$revoke = $order->revokeCertificate(); // Revoke the certificate without a reason.
$revoke = $order->revokeCertificate($reason); // Revoke the certificate with a reason integer as found in section 5.3.1 of RFC5280.
use LEClient\LEFunctions;
LEFunctions::RSAGenerateKeys($directory, $privateKeyFile, $publicKeyFile); // Generate a RSA keypair in the given directory. Variables privateKeyFile and publicKeyFile are optional and have default values private.pem and public.pem.
LEFunctions::ECGenerateKeys($directory, $privateKeyFile, $publicKeyFile); // Generate a EC keypair in the given directory (PHP 7.1+ zation); // Checks whether the HTTP challenge is valid. Performing authorizations is described further on.
LEFunctions::checkDNSChallenge($domain, $DNSDigest); // Checks whether the DNS challenge is valid. Performing authorizations is described further on.
LEFunctions::createhtaccess($directory); // Created a simple .htaccess file in the directory supplied, denying all visitors.
$client = new LEClient('[email protected]', LEClient::PRODUCTION, LEClient::LOG_OFF, 'path/to/my/key/folder/', 'my_account_folder');
$client = new LEClient('[email protected]', LEClient::PRODUCTION, LEClient::LOG_OFF, [
'public_key' => 'path/to/public/key.pem', // Required
'private_key' => 'path/to/private/key.pem', // Required
'order' => 'path/to/order.txt', // Required
'certificate' => 'path/to/certificate.crt', // One or both of certificate and fullchain_certificate
'fullchain_certificate' => 'path/to/fullchain.crt' // must be provided.
], [
'public_key' => 'path/to/account/public/key.pem', // Required
'private_key' => 'path/to/account/private/key.pem' // Required
]);
use LEClient\LEOrder;
$pending = $order->getPendingAuthorizations(LEOrder::CHALLENGE_TYPE_HTTP);