1. Go to this page and download the library: Download kengoldfarb/underscore_libs 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/ */
kengoldfarb / underscore_libs example snippets
use _\_Log;
_Log::$logLevel = _\_LogContants::INFO;
_Log::debug('This is a debug message that will not be written because of log level');
_Log::info('This is an info message');
_Log::warn('This is a warning message');
_Log::crit('This is a critical message');
_Log::fatal('Oh snap. This is a fatal error message');
use _\_Crypt;
// Set the secret key
$secretKey = "MySecretKey123";
// The text to encrypt
$textToEncrypt = "How much wood could a woodchuck chuck if a woodchuck could chuck wood?";
// The encrypted text
$encryptedText = _Crypt::_encryptAESPKCS7($textToEncrypt, $secretKey);
// The decrypted text (will match $textToEncrypt)
$decryptedText = _Crypt::_decryptAESPKCS7($encryptedText, $secretKey);
$textToEncrypt = "How much wood could a woodchuck chuck if a woodchuck could chuck wood?";
$encryptedText = _Crypt::_encryptRSA($textToEncrypt, $publicKey);
$decryptedText = _Crypt::_decryptRSA($encryptedText, $privateKey);
use _\_UUID;
$uuid = _UUID::getUUID();
use _\_UUID;
$uuid = '55a0afe6-0e00-4c08-9fb9-7905f0a106b6';
$binaryUUID = _UUID::charUUIDToBinary($uuid);
use _\_UUID;
$uuid = '55a0afe6-0e00-4c08-9fb9-7905f0a106b6';
$binaryUUID = _UUID::charUUIDToBinary($uuid);
$strUUID = _UUID::binaryUUIDToCharUUID($binaryUUID);
// At this point, $uuid == $strUUID
use _\_File;
$fileData = _File::_readAllFromFile('/tmp/myfile.txt');
if($fileData === FALSE) {
// Handle error reading from file
}
echo $fileData;
use _\_File;
$writeSuccessful = _File::_writeToFile('Here is some text for myfile.txt', '/tmp/myfile.txt');
if($writeSuccessful) {
echo $fileData;
}else{
// Hand error writing file
}
use _\_Info;
$userIp = _Info::_getUserIpAddr();
use _\_Info;
$mysqlDatetime = _Info::_mysqlNow();
use _\_Rand;
$min = 0;
$max = 100;
_Rand::_getRand($min, $max);
use _\_Rand;
$length = 10; // The number of characters in the string
$lettersNumbersOnly = true; // String will contain only letters and numbers
_Rand::_randString($length, $lettersNumbersOnly);