PHP code example of tourze / doctrine-snowflake-bundle

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

    

tourze / doctrine-snowflake-bundle example snippets


use Tourze\DoctrineSnowflakeBundle\Attribute\SnowflakeColumn;

class YourEntity
{
    #[SnowflakeColumn(prefix: 'ORDER_', length: 32)]
    private string $id;

    // ... 其他属性和方法
}

use Tourze\DoctrineSnowflakeBundle\Service\Snowflake;

class YourService
{
    public function __construct(
        private readonly Snowflake $snowflake,
    ) {
    }
    
    public function generateId(): string
    {
        return $this->snowflake->id();
    }
}