PHP code example of calicastle / cuid

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

    

calicastle / cuid example snippets


use CaliCastle\Cuid;

Cuid::make(); // ckbe1q3gi000001jsfnm9cm81
Cuid::make('u'); // ukbe1qos1000201js74bwas75

use CaliCastle\Concerns\HasCuid;

// Each user will have an id of something 
// like "ukbe1q3gi000001jsfnm9cm81"
class User extends Model 
{
   use HasCuid;

   /**
    * Get the CUID prefix.
    */
   public static function getCuidPrefix(): string
   {
       return 'u';
   }
}