PHP code example of youthage / snowflake
1. Go to this page and download the library: Download youthage/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/ */
youthage / snowflake example snippets
composer
#工作机器ID, 0-1023
config目录下创建baseconfig.php
内容为
return [
'SNOWFLAKE_WORK_ID' => 1
];
namespace App\Http\Controllers;
use Snowflake;
class IndexController extends Controller
{
public function index()
{
$id = Snowflake::nextId();
echo $id;
}
}