PHP code example of mitoop / laravel-snowflake

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

    

mitoop / laravel-snowflake example snippets


return [
    // 纪元时间
    'epoch' => '2023-08-01 00:00:00',
    // 数据中心id 范围:[0-31]. 为 null时, 随机取[0-31]的值
    'datacenter_id' => null,
    // 工作机器id 范围:[0-31]. 为 null时, 随机取[0-31]的值
    'worker_id' => null,
    // 序列号生成策略类 为 null 时, 使用随机数. 自定义策略请返回闭包.
    'sequence_strategy' => null,
];

    Schema::create('tests', function (Blueprint $table){
         $table->snowflake()->primary();
         $table->snowflake('another_snowflake_id');
         $table->timestamps();
    });
shell
php artisan vendor:publish --provider="Mitoop\LaravelSnowflake\ServiceProvider"