PHPackages                             abolotin/yii2-unique-id - 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. abolotin/yii2-unique-id

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

abolotin/yii2-unique-id
=======================

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

1.0.2(8y ago)028BSD-3-ClausePHPPHP &gt;=5.3.0

Since May 8Pushed 8y agoCompare

[ Source](https://github.com/abolotin/yii2-unique-id)[ Packagist](https://packagist.org/packages/abolotin/yii2-unique-id)[ RSS](/packages/abolotin-yii2-unique-id/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (1)Versions (7)Used By (0)

Unique widget's IDs generator
=============================

[](#unique-widgets-ids-generator)

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

Standard Yii2 generator use prefix "w" and simple counter of generated IDs. It's enougth while non-AJAX requests used. But if you're want to load some page content via AJAX-request, you're can obtain HTML-elements with same IDs ("w1", for example). So, some scripts, based on element's ID, will work unexpectedly. Such behaviour may be bypassed by specifying ID manually in code. Another way is setting up Widget::$autoIdPrefix.

Installation
============

[](#installation)

Using Composer
--------------

[](#using-composer)

You can use the composer package manager to install. Either run:

$ php composer.phar require abolotin/yii2-unique-id

or add:

"abolotin/yii2-unique-id": ""

to your composer.json file

Manual Install
--------------

[](#manual-install)

You can also manually install the component easily to your project. Just download the source [ZIP](https://github.com/abolotin/yii2-unique-id/zipball/master) or [TAR ball](https://github.com/abolotin/yii2-unique-id/tarball/master)

Usage
=====

[](#usage)

Using in manual mode
--------------------

[](#using-in-manual-mode)

Just call \\abolotin\\yii2\\UniqueId::getId(). It's returns unique value, which can be assigned to "id" attribute of HTML-element.

Using in automatic mode
-----------------------

[](#using-in-automatic-mode)

You're can to setup automatic generation of IDs by any \\yii\\base\\Widget based objects. Just add '\\abolotin\\yii2\\UniqueId' string to 'bootstrap' array of applications configuraion:

```
return [
   ...
   'bootstrap' => [
       '\\abolotin\\yii2\\UniqueId',
       ...
   ]
];
```

or using component's mode:

```
return [
   ...
   'components' => [
       'uniqueId' => [
           'class' => '\\abolotin\\yii2\\UniqueId',
           ...
       ],
       ...
   ],
   'bootstrap' => [
       'uniqueId',
       ...
   ]
];
```

In last case it's can be also configured.

Configuration
-------------

[](#configuration)

Component allows next configuration options:

**widgetPrefix** - string. First prefix, used by widget generator. Default value: 'w'.

**pjaxPrefix** - string. First prefix, used by Pjax widget generator. Default value: 'p'.

**autoIdPrefix** - string. Second prefix, used by generator. If unspecified, will be generated automatically.

**counter** - integer. Inner generated IDs counter. Default value: 0.

**suffix** - string. Suffix of inner generated ID. Default value: 't'.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~1 days

Total

3

Last Release

2925d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/53d48095af289b132b4c1f4576db8f46734784537f6cc5c2fe506e802673995b?d=identicon)[abolotin](/maintainers/abolotin)

---

Top Contributors

[![abolotin](https://avatars.githubusercontent.com/u/36935837?v=4)](https://github.com/abolotin "abolotin (29 commits)")

---

Tags

phpyii2

### Embed Badge

![Health badge](/badges/abolotin-yii2-unique-id/health.svg)

```
[![Health](https://phpackages.com/badges/abolotin-yii2-unique-id/health.svg)](https://phpackages.com/packages/abolotin-yii2-unique-id)
```

PHPackages © 2026

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