PHP code example of dariusiii / token

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

    

dariusiii / token example snippets


// Generate unique Token From Database.
$new_token = $token->Unique($table_name, $column_name, $size);


DariusIII\Token\TokenServiceProvider::class

'Token'=>\DariusIII\Token\Facades\Facade::class

  Const DT_Unique = 'Unique'; 
  Const DT_UniqueNum = 'UniqueNumber'; 
  Const DT_UniqueStr = 'UniqueString';
  Const DT_Random = 'Random';
  Const DT_RandomNum = 'RandomNumber';
  Const DT_RandomStr = 'RandomString';
  

           $user=User::first();
           $user->setToken();
           $user->save();

           $user=User::first();
           $user->setToken(DT_UniqueStr,100,false);
           $user->save();

            $user=User::first();
            $user->setToken(DT_UniqueStr,100,false,'column_name');
            $user->save();
 

  protected $DMT_columns=[
        'unique_id'=>['type'=>DT_Unique,'size'=>60,'special_chr'=>false],
        'unique_uid'=>['type'=>DT_Unique,'size'=>30,'special_chr'=>false],
    ];


    Const DT_Unique = 'Unique'; 
    Const DT_UniqueNum = 'UniqueNumber'; 
    Const DT_UniqueStr = 'UniqueString';
    Const DT_Random = 'Random';
    Const DT_RandomNum = 'RandomNumber';
    Const DT_RandomStr = 'RandomString';
    

             $user=User::first();
             $user->setTokens();
             $user->save();
  


// Generate unique token not rebeated in database table with column name 
Token::Unique($table_name, $column_name, 10 );
//Result: fCWih6TDAf


// Generate unique integer token not rebeated in database table with column name
Token::UniqueNumber($table_name, $column_name, 10 );
//Result: 9647307239


// Generate unique string token not rebeated in database table with column name
Token::UniqueString($table_name, $column_name, 10 );
//Result: SOUjkyAyxC


//You can use special characters just add "true" to the function
Token::Unique($table_name, $column_name, 10,true );
//Result: H@klU$u^3z

$size=10;
// Generate random token 
Token::Random($size);

// Generate random integer token
Token::RandomNumber($size);

// Generate random string token
Token::RandomString($size);

//You can use special characters just add "true" to the function
Token::Random($size,true);