1. Go to this page and download the library: Download swindon/code-generator 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/ */
swindon / code-generator example snippets
/**
* Generates a random code
*
* @param $length int
* @return string
*/
->generate(int $length = 8) : string
(new CodeGenerator)->generate(12);
// output: 4CF9O7XP
(new CodeGenerator)->setCharacters(CodeGenerator::CHAR_ALPHA)->generate(8);
// output: JTFRujQJ
(new CodeGenerator)->setCharacters(CodeGenerator::CHAR_ALL)->generate(10);
// output: J\TTu@<ab4
(new CodeGenerator)->setCharacters('ABCXYZabcxyz')->generate(6);
// output: XcZxbc
/**
* Generates an array of random codes
*
* @param $maxNum int
* @param $length int
* @return array
*/
->bulk(int $maxNum, int $length = 8) : array
(new CodeGenerator)->setCharacters('ABC')->bulk(100, 3);
// throws: 'Cannot generate more than 27 possible unique codes. Try increasing the code length.'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.