PHP code example of webcraft / laravel-random

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

    

webcraft / laravel-random example snippets


// config/app.php

'providers' => [
    ...
    Webcraft\Random\RandomServiceProvider::class,
    ...
];

// config/app.php

'aliases' => [
	  ...
        'Random' => Webcraft\Random\RandomFacade::class
    ...
]

// Generate a random string that is 32 bytes in length.
$string = Random::generate(32);

// Generate a whole number between 5 and 15.
$int = Random::generateInt(5, 15);

// Generate a 32 character string that only contains the letters
// 'a', 'b', 'c', 'd', 'e', and 'f'.
$string = Random::generateString(32, 'abcdef');

// Give the character list 'abcdef':
print Random::generateString(32, 'abcdef')."\n";

// One would expect to receive output that only contained those
// characters:
//
// adaeabecfbddcdaeedaedfbbcdccccfe
// adfbfdbfddadbfcbbefebcacbefafffa
// ceeadbcabecbccacdcaabbdccfadbafe
// abadcffabdcacdbcbafcaecabafcdbbf
// dbdbddacdeaceabfaefcbfafebcacdca
bash
php artisan vendor:publish --provider="Webcraft\Random\RandomServiceProvider"