PHPackages                             bond211/php-colors - 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. bond211/php-colors

Abandoned → [bondarde/php-colors](/?search=bondarde%2Fphp-colors)Library

bond211/php-colors
==================

PHP colors handler

v1.2.0(4mo ago)022MITPHPPHP ^8.0CI passing

Since Dec 12Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/bondarde/php-colors)[ Packagist](https://packagist.org/packages/bond211/php-colors)[ RSS](/packages/bond211-php-colors/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (2)Versions (16)Used By (0)

PHP Colors
==========

[](#php-colors)

Creating color
--------------

[](#creating-color)

**Hex**

Lowercase, uppercase, with/without hash:

```
Color::fromHex('#0f4c81');
Color::fromHex('#0F4C81');
Color::fromHex('0f4c81');
Color::fromHex('0F4C81');

```

**RGB**

Integers, floats, indexed or associative array of integers/floats:

```
Color::fromRgb(15, 76, 129);
Color::fromRgb([15, 76, 129]);
Color::fromRgb([
    'r' => 15,
    'g' => 76,
    'b' => 129,
]);

Color::fromRgb(0.06, 0.3, 0.51);
Color::fromRgb([0.06, 0.3, 0.51]);
Color::fromRgb([
    'r' => 0.06,
    'g' => 0.3,
    'b' => 0.51,
]);

```

**HSL**

Integers, floats, indexed or associative array of integers/floats:

```
Color::fromHsl(208, 79, 28);
Color::fromHsl([208, 79, 28]);
Color::fromHsl([
    'h' => 208,
    's' => 79,
    'l' => 28,
]);

Color::fromHsl(0.58, 0.79, 0.28);
Color::fromHsl([0.58, 0.79, 0.28]);
Color::fromHsl([
    'h' => 208,
    's' => 79,
    'l' => 28,
]);

Color::fromHsl([208, 0.79, 0.28]);

```

**HSV**

Integers, floats, indexed or associative array of integers/floats:

```
Color::fromHsv(208, 88, 51);
Color::fromHsv([208, 88, 51]);
Color::fromHsv([
    'h' => 208,
    's' => 88,
    'v' => 51,
]);

Color::fromHsv(0.58, 0.88, 0.51);
Color::fromHsv([0.58, 0.88, 0.51]);
Color::fromHsv([
    'h' => 0.58,
    's' => 0.88,
    'v' => 0.51,
]);

Color::fromHsv(208, 0.88, 0.51);

```

**CMYK**

Integers, floats, indexed or associative array of integers/floats:

```
Color::fromCmyk(88, 41, 0, 49);
Color::fromCmyk([88, 41, 0, 49]);
Color::fromCmyk([
    'c' => 88,
    'm' => 41,
    'y' => 0,
    'k' => 49,
]);

Color::fromCmyk(0.88, 0.41, 0, 0.49);
Color::fromCmyk([0.88, 0.41, 0, 0.49]);
Color::fromCmyk([
    'c' => 0.88,
    'm' => 0.41,
    'y' => 0,
    'k' => 0.49,
]);

```

### Random

[](#random)

Generate random color:

```
Color::random();

```

Just `echo` it
--------------

[](#just-echo-it)

You can use a `Color` object as string:

```
echo Color::fromHex('#0f4c81');

```

Color manipulations
-------------------

[](#color-manipulations)

```
$color->rotate(120);
$color->complementary();

```

Useful Information
------------------

[](#useful-information)

E.g. to decide which font color to use with given background color you can detect whether the color is bright or dark:

```
$color->isBright();
$color->isDark();

```

Distance of RGB values for two given colors:

```
$color->distanceRgb($anotherColor);

```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance74

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

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 ~157 days

Recently: every ~238 days

Total

15

Last Release

144d ago

Major Versions

v0.8.1 → v1.0.02023-05-13

PHP version history (2 changes)v0.1.0PHP ^7.2

v0.8.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7894e69f9e9f2e9608e7a3f221b9285295ab7a5ee3016600e66ca4e8109c09b0?d=identicon)[bondar](/maintainers/bondar)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/bond211-php-colors/health.svg)

```
[![Health](https://phpackages.com/badges/bond211-php-colors/health.svg)](https://phpackages.com/packages/bond211-php-colors)
```

PHPackages © 2026

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