PHPackages                             flashytime/id-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. flashytime/id-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

flashytime/id-generator
=======================

ID Generator based on Apc and MySQL

v1.0.0(8y ago)16MITPHPPHP &gt;=5.6

Since May 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/flashytime/id-generator)[ Packagist](https://packagist.org/packages/flashytime/id-generator)[ RSS](/packages/flashytime-id-generator/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

ID Generator
============

[](#id-generator)

ID Generator based on Apc and MySQL which can be used to generate primary key for sharding mysql tables.

Installation
------------

[](#installation)

- Run the composer require command from your terminal:

```
composer require flashytime/id-generator
```

- Create a mysql table named 'id\_generator' with the `id_generator.sql`:

```
CREATE TABLE `id_generator` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL COMMENT '名字',
  `current_id` bigint(20) unsigned NOT NULL COMMENT '当前最大ID',
  `step` int(11) unsigned NOT NULL COMMENT '步长',
  `length` int(11) unsigned NOT NULL COMMENT '缓存步长',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ID生成器';
```

- Copy the `id-generator.php` file from the config directory to `config/id-generator.php`

Usage
-----

[](#usage)

```
$idGenerator = new \Flashytime\ApcIdGenerator\IdGenerator($config);
$idGenerator->setTable('id_generator');
$id = $idGenerator->getId('test_name');
```

Laravel and Lumen
-----------------

[](#laravel-and-lumen)

#### Laravel 5

[](#laravel-5)

Add a ServiceProvider to your providers array in `config/app.php`:

```
'providers' => [

	Flashytime\IdGenerator\Provider\LaravelIdGeneratorServiceProvider::class,

]
```

Finally, publish the configuration files via `php artisan vendor:publish`.

#### Lumen

[](#lumen)

For `Lumen` add the following in your bootstrap/app.php

```
$app->register(Flashytime\IdGenerator\Provider\LumenIdGeneratorServiceProvider::class);
```

Copy the `id-generator.php` file from the config directory to `config/id-generator.php`

And also add the following to bootstrap/app.php

```
$app->configure('id-generator');
```

#### Usage

[](#usage-1)

```
app('id-generator')->setTable('id_generator');
$id = app('id-generator')->getId('test_name');
```

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2974d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4725967?v=4)[flashytime](/maintainers/flashytime)[@flashytime](https://github.com/flashytime)

---

Top Contributors

[![flashytime](https://avatars.githubusercontent.com/u/4725967?v=4)](https://github.com/flashytime "flashytime (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flashytime-id-generator/health.svg)

```
[![Health](https://phpackages.com/badges/flashytime-id-generator/health.svg)](https://phpackages.com/packages/flashytime-id-generator)
```

###  Alternatives

[oveleon/contao-cookiebar

Contao Cookiebar

62128.1k8](/packages/oveleon-contao-cookiebar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
