dev-master
9999999-dev https://github.com/danielthegeek/rand-genRandom string generator for the CodeIgniter framework
MIT
The Requires
- php >=5.2.4
by Daniel Omoniyi
library generator codeigniter string random danielomoniyi randgen
Wallogit.com
2017 © Pedro Peláez
Random string generator for the CodeIgniter framework
CodeIgniter random string generator library. This library can be used for generating ticket ID's, user ID's or anything that needs randomness :-)., (*1)
Install Composer to your project root:, (*2)
$ curl -sS https://getcomposer.org/installer | php
Add a composer.json file to your project:, (*3)
{
"require": {
"danielthegeek/rand-gen": "dev-master"
}
}
php composer.phar install
Copy the Rand_gen.php file from path/to/project/vendor/danielthegeek/rand-gen/src to your CI library folder normally located at path/to/project/application/libraries. For example:, (*4)
$ cd /var/www/html/example-project $ cp vendor/danielthegeek/rand-gen/src/Rand_gen.php application/libraries
And you're good to go., (*5)
public function myFunction()
{
$this->load->library('rand_gen');
}
```
or auto load the library if you plan on using it frequently by editing `application/config/autoload.php`
```php
$autoload['libraries'] = array('rand_gen');
Call the generate() method. The generate() method accepts two arguments: Length (Int) and Type ('alpha'|'numeric'|'alpha-numeric')., (*6)
| Arguments | Description | Value |
|---|---|---|
| Length | The length of the string to be generated | alpha, numeric, alpha-numeric |
| Type | The string type to be generated. | Int |
The string type value can be:
* alpha - Generates a string that contains only alphabets,
* numeric - Generates a string that contains only numbers or
* alpha-numeric - Generates a string that contains a combination of alphabets and numbers
If a string type is not defined, the default combination will be used.
For example:, (*7)
rand_gen->generate(100);
echo $randString;
// Random string of 30 characters containing only alphabets
$randAlphaString = $this->rand_gen->generate(30, 'alpha');
echo $randAlphaString;
// Random string of 250 characters containing only numbers
$randNumString = $this->rand_gen->generate(250, 'numeric');
echo $randNumString;
// Random string of 50 characters containing only alphabets and numbers
$randAlphanumString = $this->rand_gen->generate(50, 'alpha-numeric');
echo $randAlphanumString;
?>
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT License, (*8)
Random string generator for the CodeIgniter framework
MIT
library generator codeigniter string random danielomoniyi randgen