PHP code example of maxsky / laravel-snowflake

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

    

maxsky / laravel-snowflake example snippets


SNOWFLAKE_EPOCH='2019-05-01 00:00:00'
SNOWFLAKE_WORKER_ID=1
SNOWFLAKE_DATACENTER_ID=1

$snowflake = app('Snowflake\Snowflake');

$id = $snowflake->next();



namespace App;

use Snowflake\HasSnowflakePrimary;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable {

    use HasSnowflakePrimary, Notifiable;

    /**
     * Indicates if the IDs are auto-incrementing.
     *
     * @var bool
     */
    public $incrementing = false;
}

/**
 * Run the migrations.
 *
 * @return void
 */
public function up() {
    Schema::create('users', function (Blueprint $table) {
        // $table->increments('id');
        $table->bigInteger('id')->primary();
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}
bash
# Just Laravel
php artisan vendor:publish