PHP code example of parsidev / randomizr

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

    

parsidev / randomizr example snippets


'providers' => [
    ...
    Parsidev\Support\Providers\RandomizrServiceProvider::class,
],

// @file app/config/app.php

'aliases' => [
    ...
    'Randomizr' => Parsidev\Support\Facades\Randomizr::class,
],

// @file app/config/app.php

randomizr('vowel')->make();
randomizr('num')->make();
...

// Set the max length to 16
randomizr('consonant')->make(16);

// Set the minimum length to 2
randomizr('num')->make(16, 2);

randomizr('num_dash_underscore')->make();
// or, if you prefer
randomizr('numDashUnderscore')->make();

// Using charsets only
randomizr('vowel_consonant_num')->make();

// Using the `alpha` alias to merge `vowel` and `consonant`
randomizr('alpha_num')->make();

randomizr('alpha_punctuation')->unique('path/to/dir');

randomizr('lowercase_dash')->unique('tablename@field');

randomizr('string')->unique('path/to/dir', 16, 6);

randomizr('alpha_num')->make();
// equals
randomizr('alphaNum')->make();
// equals
Randomizr::alpha_num()->make();
// equals
Randomizr::alphaNum()->make();

str_starts_with('a', 'abc'); // returns true
str_starts_with('b', 'abc'); // returns false

str_ends_with('de', 'abcde'); // returns true
str_ends_with('cd', 'abcde'); // returns false

'charsets' => array(
    ...
    'mycharsetname' => 'characters_for_this_charset'
),

'aliases' => array(
    ...
    'id' => "alpha|dash"
),

'aliases' => array(
    ...
    'id' => "alpha|dash|'.'"
),

'aliases' => array(
    ...
    'id' => "consonant|6", // the result will be 'aeijoy6'
),

'aliases' => array(
    ...
    'uspecial' => "strtoupper:special"
),

'aliases' => array(
    ...
    'notnull'   => "str_replace:0,'',num", // results in '123456789'
    'custom'    => "my_custom_function:'arg1',num"
),

$ php artisan randomizr:publish