1. Go to this page and download the library: Download seffeng/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/ */
# 示例
use Seffeng\LaravelSnowflake\Facades\Snowflake;
class SiteController extends Controller
{
public function test()
{
// 生成雪花ID
var_dump(Snowflake::id());
}
}
# Model 示例
use Illuminate\Database\Eloquent\Model;
use Seffeng\LaravelSnowflake\Traits\SnowflakePrimary;
class User extends Model {
// $model->save() 时自动使用雪花ID
use SnowflakePrimary;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.