PHPackages                             mistic100/randomcolor - 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. mistic100/randomcolor

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

mistic100/randomcolor
=====================

Generate attractive random colors

1.1.0(1y ago)2461.5M↓19.2%58[1 PRs](https://github.com/mistic100/RandomColor.php/pulls)6MITPHP

Since Dec 10Pushed 1y ago16 watchersCompare

[ Source](https://github.com/mistic100/RandomColor.php)[ Packagist](https://packagist.org/packages/mistic100/randomcolor)[ Docs](https://github.com/mistic100/RandomColor.php)[ RSS](/packages/mistic100-randomcolor/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (8)DependenciesVersions (8)Used By (6)

Random Color
============

[](#random-color)

[![PHP version](https://camo.githubusercontent.com/15f5b475f1ec7f8577d2d0ccae74ab728b4e7b54e61c3b0f4de1c299658a9a5e/68747470733a2f2f62616467652e667572792e696f2f70682f6d697374696331303025324672616e646f6d636f6c6f722e737667)](http://badge.fury.io/ph/mistic100%2Frandomcolor)

For generating attractive random colors.

This is a PHP port of David Merfield [randomColor](https://github.com/davidmerfield/randomColor) Javascript utility.

See the results on [the demo](http://www.strangeplanet.fr/work/RandomColor.php).

[![Demo](https://raw.githubusercontent.com/mistic100/RandomColor.php/master/demo/screenshot.jpg)](http://www.strangeplanet.fr/work/RandomColor.php)

### Options

[](#options)

You can pass an options object to influence the type of color it produces. The options object accepts the following properties:

**hue** – Controls the hue of the generated color. You can pass a string representing a color name (e.g. 'orange'). Possible color names are *red, orange, yellow, green, blue, purple, pink and monochrome*. You can also pass an array of multiple hues or a specific hue (0 to 360).

**luminosity** – Controls the luminosity of the generated color. You can pass a string containing *bright, light or dark*.

**alpha** – A decimal between 0 and 1. Only relevant when using a format with an alpha channel. Defaults to a random value.

**format** – A string which specifies the format of the generated color. Possible values are *hsv, hsl, hslCss, rgb, rgbCss, hex* and their alpha variants *hsva, hsla, hlsaCss, rgba, rgbaCss, hexa*. Defaults to *hex*.

**prng** – A random (or not) number generator. `mt_rand` is used as default one.

### Examples

[](#examples)

```
use \Colors\RandomColor;

// Returns a hex code for an attractive color
RandomColor::one();

// Returns an array of ten green colors
RandomColor::many(10, array(
   'hue' => 'green',
));

// Returns a hex code for a light blue
RandomColor::one(array(
   'luminosity' => 'light',
   'hue' => 'blue',
));

// Returns one yellow or blue color
RandomColors::one(array(
    'hue' => array('yellow', 'blue'),
));

// Returns a hex code for a 'truly random' color
RandomColor::one(array(
   'luminosity' => 'random',
   'hue' => 'random',
));

// Returns a bright color in RGB
RandomColor::one(array(
   'luminosity' => 'bright',
   'format' => 'rgbCss', // e.g. 'rgb(225,200,20)'
));

// Returns a RGB color with random alpha
RandomColor::one(array(
   'format': 'rgbaCss', // e.g. 'rgba(9, 1, 107, 0.648)'
));

// Returns an hex color with specified alpha
RandomColor::one(array(
   'format': 'hexa',
   'alpha': 0.5, // e.g.: #c17d3480
));
```

### Other languages

[](#other-languages)

RandomColor is available in [JavaScript](https://github.com/davidmerfield/randomColor), [C#](https://github.com/nathanpjones/randomColorSharped), [C++](https://github.com/xuboying/randomcolor-cpp), [Go](https://github.com/hansrodtang/randomcolor), [Haskell](http://hackage.haskell.org/package/palette-0.3/docs/Data-Colour-Palette-RandomColor.html), [Kotlin](https://github.com/brian-norman/RandomKolor), [Mathematica](https://github.com/yuluyan/PrettyRandomColor), [Python](https://github.com/kevinwuhoo/randomcolor-py), [Swift](https://github.com/onevcat/RandomColorSwift), [Perl6](https://github.com/Xliff/p6-RandomColor), [Objective-C](https://github.com/yageek/randomColor), [Java](https://github.com/lzyzsd/AndroidRandomColor), [R](https://github.com/ronammar/randomcoloR), [Reason](https://github.com/ktrzos/bs-randomColor), [Dart](https://github.com/DAMMAK/RandomColorDart), [Ruby](https://github.com/khash/random_color), [Rust](https://github.com/elementh/random_color) and [Swift](https://github.com/onevcat/RandomColorSwift).

### License

[](#license)

This project is licensed under the terms of the MIT license.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity59

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~593 days

Recently: every ~816 days

Total

7

Last Release

638d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57f5fc656e63b7c6e070e25682e632d2dc1204dd6542fef5def1891b68b0d883?d=identicon)[mistic100](/maintainers/mistic100)

---

Top Contributors

[![mistic100](https://avatars.githubusercontent.com/u/41597?v=4)](https://github.com/mistic100 "mistic100 (18 commits)")[![mundschenk-at](https://avatars.githubusercontent.com/u/6943905?v=4)](https://github.com/mundschenk-at "mundschenk-at (1 commits)")[![rieschl](https://avatars.githubusercontent.com/u/3321556?v=4)](https://github.com/rieschl "rieschl (1 commits)")

---

Tags

randomgeneratorcolor

### Embed Badge

![Health badge](/badges/mistic100-randomcolor/health.svg)

```
[![Health](https://phpackages.com/badges/mistic100-randomcolor/health.svg)](https://phpackages.com/packages/mistic100-randomcolor)
```

###  Alternatives

[ihor/nspl

Non-standard PHP library (NSPL) - functional primitives toolbox and more

381369.1k](/packages/ihor-nspl)[nubs/random-name-generator

A library to create interesting, sometimes entertaining, random names.

132705.1k3](/packages/nubs-random-name-generator)[gladcodes/keygen

A fluent PHP random key generator.

123759.9k2](/packages/gladcodes-keygen)[genphrase/genphrase

Secure passphrase generator for PHP applications

117312.1k4](/packages/genphrase-genphrase)[hi-folks/rando-php

Random generator Library for PHP

12889.8k2](/packages/hi-folks-rando-php)[markrogoyski/itertools-php

Iteration tools for PHP

14912.2k](/packages/markrogoyski-itertools-php)

PHPackages © 2026

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