PHP code example of septech-laravel / snowflake

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

    

septech-laravel / snowflake example snippets


composer c config
php artisan vendor:publish --provider="Septech\\Snowflake\\SnowflakeServiceProvider"


use Septech\Snowflake\Facades\Snowflake;

Snowflake::next(); // Alias for id()
Snowflake::id();
Snowflake::parseId('6696174721395998720');


// -- routes/api.php
use Septech\Snowflake\Facades\Snowflake;

Snowflake::routes();

use Septech\Snowflake\Facades\Snowflake;

Route::group(['prefix' => '/snowflake'], function () {
    Snowflake::routes();
});


Route::group(['middleware' => \Septech\Snowflake\Http\Middleware\ServerToken::class], function () {
    Snowflake::routes();
});


// app/Http/Kernel.php
protected $routeMiddleware = [
    // ...
    'server_token' => \Septech\Snowflake\Http\Middleware\ServerToken::class
    // ...
];

// routes/api.php
Route::group(['middleware' => 'server_token'], function () {
    Snowflake::routes();
});


# 
SNOWFLAKE_EPOCH="2019-07-01 00:00:00"


php artisan worker:token

php artisan worker:token --force