PHPackages                             sjaakp/yii2-random-provider - 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. sjaakp/yii2-random-provider

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

sjaakp/yii2-random-provider
===========================

Random ActiveDataProvider for Yii 2.0 GridView or ListView

1.0.2(1y ago)0141MITPHP

Since Dec 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sjaakp/yii2-random-provider)[ Packagist](https://packagist.org/packages/sjaakp/yii2-random-provider)[ RSS](/packages/sjaakp-yii2-random-provider/feed)WikiDiscussions master Synced 2d ago

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

yii2-random-provider
====================

[](#yii2-random-provider)

#### ActiveDataProvider with random selection

[](#activedataprovider-with-random-selection)

[![Latest Stable Version](https://camo.githubusercontent.com/a8d8247ffdc0f5cdf9907f258c045ec435fbb66cbff3df29ad1fbbab8d208347/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d72616e646f6d2d70726f76696465722f762f737461626c65)](https://packagist.org/packages/sjaakp/yii2-random-provider)[![Total Downloads](https://camo.githubusercontent.com/5107006ab9581ecea87388d9b13fdc067c30cd2fe3bc7a83c86428238387343a/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d72616e646f6d2d70726f76696465722f646f776e6c6f616473)](https://packagist.org/packages/sjaakp/yii2-random-provider)[![License](https://camo.githubusercontent.com/b354f13c6f5b7a7dfbd1a4a95155e123051b659cbdc49416ea4f6f58cb2190b2/68747470733a2f2f706f7365722e707567782e6f72672f736a61616b702f796969322d72616e646f6d2d70726f76696465722f6c6963656e7365)](https://packagist.org/packages/sjaakp/yii2-random-provider)

**RandomProvider** is derived from [**ActiveDataProvider**](https://www.yiiframework.com/doc/api/2.0/yii-data-activedataprovider)of the [Yii 2.0](https://www.yiiframework.com/ "Yii") PHP Framework. It selects the records in a random fashion, which in some cases may be more attractive than the orderly way a regular **ActiveDataProvider** (usually) does it. **RandomProvider** is intended to co-operate with my [**LoadMorePager**](https://sjaakpriester.nl/software/loadmore), but it will work with [**LinkPager**](https://www.yiiframework.com/doc/api/2.0/yii-widgets-linkpager) or other pagers as well.

Notice that **RandomProvider** doesn't support `CUBRID` or `dblib` database drivers. Moreover, I only tested it with `mysql`. I'm pretty sure it'll work with other drivers, though. If you have any experiences to share, I'll appreciate that.

Notice also that **RandomProvider** makes use of an algorithm named '*Order By Rand()*'. This is rather slow, and doesn't scale very well. Therefore, it is advised to use **RandomProvider** only with relatively small data sets (think of less than a few thousands of records). More information [here](https://www.warpconduit.net/2011/03/23/selecting-a-random-record-using-mysql-benchmark-results/).

A demonstration of **RandomProvider** is [here](http://www.sjaakpriester.nl/software/randomprovider).

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

[](#installation)

Install **yii2-random-provider** in the usual way with [Composer](https://getcomposer.org/). Add the following to the `require` section of your `composer.json` file:

`"sjaakp/yii2-random-provider": "*"`

or run:

`composer require sjaakp/yii2-random-provider`

You can manually install **yii2-random-provider** by [downloading the source in ZIP-format](https://github.com/sjaakp/yii2-random-provider/archive/master.zip).

Using RandomProvider
--------------------

[](#using-randomprovider)

**RandomProvider** is a drop-in replacement for Yii's [**ActiveDataProvider**](https://www.yiiframework.com/doc/api/2.0/yii-data-activedataprovider). Just use it like **ActiveDataProvider**.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~831 days

Total

3

Last Release

684d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/156f636aceedc73021a2bfafb5433271c2c55d6cf4bce06b12902c85b4b491f1?d=identicon)[sjaakp](/maintainers/sjaakp)

---

Top Contributors

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

---

Tags

randomdatayii2extensionyiigridviewListView

### Embed Badge

![Health badge](/badges/sjaakp-yii2-random-provider/health.svg)

```
[![Health](https://phpackages.com/badges/sjaakp-yii2-random-provider/health.svg)](https://phpackages.com/packages/sjaakp-yii2-random-provider)
```

###  Alternatives

[sjaakp/yii2-alphapager

Page data on initial character in Yii2.

184.4k](/packages/sjaakp-yii2-alphapager)

PHPackages © 2026

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