PHP code example of fanmade / laravel-nanoid

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

    

fanmade / laravel-nanoid example snippets


use Fanmade\NanoId\Facades\NanoID;

echo NanoID::generate(); // Returns a Nano ID

echo NanoID::generate(length: 10); // Returns a Nano ID with a length of 10

echo NanoID::generate(length: 10, prefix: 'prefix_'); // Returns a Nano ID with a length of 10 and a prefix of 'prefix_'

echo NanoID::generate(suffix: '_suffix'); // Returns a Nano ID with a suffix of '_suffix'

echo NanoID::generate(alphabet: '0123456789'); // Returns a Nano ID only containing numbers

echo nano_id(); // The helper function accepts the same parameters as the generate method
bash
php artisan vendor:publish --tag=nanoid-config