PHP code example of codiliateur / smart-uuid

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

    

codiliateur / smart-uuid example snippets


use /Codiliateur/SmartUuid/Models/HasUuidPrimaryKey;

class MyModel extends Model
{
	use HasUuidPrimaryKey
	
	public $appCode = 0x002;

	public $entityCode = 0x000F;

}


$uuid = generate_uuid(0xF,0x2);
echo $uuid; // 622235ea-8e54-f002-000f-742c8deebf77

$uuid = gen_uuid(0xF,0x2);
echo extract_uuid_part($uuid, 'timestamp', 1);
// Carbon\Carbon @1701626403 {#6267
//    date: 2023-12-03 18:00:03.502460 UTC (+00:00),
// }

echo extract_uuid_part($uuid, 'timestamp', 'Y-m-d H:i:s.u');
// DateTime @1701626403 {#6317
//    date: 2023-12-03 18:00:03.502460 UTC (+00:00),
// }

echo extract_uuid_part($uuid, 'timestamp', 'Y-m-d H:i:s.u');
// 2023-12-04 19:00:39.906514

$uuid = gen_uuid(0xF,0x2);
echo extract_uuid_part($uuid, 'app_code');
// 2

$uuid = gen_uuid(0xF,0x2);
echo extract_uuid_part($uuid, 'entity_code');
// 15