PHPackages                             nabeghe/colory - 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. nabeghe/colory

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

nabeghe/colory
==============

Simple colors helper for PHP.

0.1.0(1y ago)494MITPHPPHP &gt;=5.6

Since Oct 22Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/nabeghe/colory-php)[ Packagist](https://packagist.org/packages/nabeghe/colory)[ Docs](https://github.com/nabeghe/colory-php)[ RSS](/packages/nabeghe-colory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Colory for PHP.
===============

[](#colory-for-php)

> Simple colors helper for PHP.

Generating random RGB &amp; HEX colors with alpha capability, Inverting RGB and HEX colors, converting between RGB and HEX colors &amp; perhaps more features in the future.

🫡 Usage
-------

[](#-usage)

### 🚀 Installation

[](#-installation)

You can install the package via composer:

```
composer require nabeghe/colory
```

#### Example:

[](#example)

```
use Nabeghe\Colory\Colory;

echo "[[ Random RBG ]]\n";
echo "> Random RBG => ".json_encode(Colory::randomRgb())."\n";
echo "> Random RGBA => ".json_encode(Colory::randomRgb(true))."\n";
echo '> Random RGB for CSS => '.json_encode(Colory::randomRgbCss())."\n";
echo '> Random RGBA for CSS => '.json_encode(Colory::randomRgbCss(true))."\n";
echo "\n";

echo "[[ Random Hex ]]\n";
echo '> Random Hex => '.json_encode(Colory::randomHex())."\n";
echo '> Random Hex With Alpha => '.json_encode(Colory::randomHex(true))."\n";
echo "\n";

echo "[[ Invert RGB ]]\n";
$random_rgb = Colory::randomRgb();
echo "> Invert RGB ($random_rgb[r], $random_rgb[g], $random_rgb[b]) => ".json_encode(Colory::invertRgb($random_rgb))."\n";
$random_rgba = Colory::randomRgb(true);
echo "> Invert RGBA ($random_rgba[r], $random_rgba[g], $random_rgba[b], $random_rgba[a]) => ".json_encode(Colory::invertRgb($random_rgba))."\n";
echo "> Invert RGBA (nabeghe/colory) => ".json_encode(Colory::invertRgb('nabeghe/colory'))."\n";
echo "\n";

echo "[[ Invert HEX ]]\n";
$random_hex = Colory::randomHex();
echo "> Invert HEX ($random_hex) => ".json_encode(Colory::invertHex($random_hex))."\n";
$random_hexa = Colory::randomHex(true);
echo "> Invert HEX ($random_hexa) => ".json_encode(Colory::invertHex($random_hexa))."\n";
echo '> Invert HEX (#EEE) => '.json_encode(Colory::invertHex('#EEE'))."\n";
echo '> Invert HEX (#eee) => '.json_encode(Colory::invertHex('#eee'))."\n";
echo '> Invert HEX (#FFF) => '.json_encode(Colory::invertHex('#FFF'))."\n";
echo '> Invert HEX (#fff) => '.json_encode(Colory::invertHex('#fff'))."\n";
echo '> Invert HEX (#ff573380) => '.json_encode(Colory::invertHex('#ff573380'))."\n";
echo '> Invert HEX (nabeghe/colory) => '.json_encode(Colory::invertHex('nabeghe/colory'))."\n"; // null
echo "\n";

echo "[[ RGB To HEX ]]\n";
$random_rgb = Colory::randomRgb();
echo "> RGB To HEX ($random_rgb[r], $random_rgb[g], $random_rgb[b]) => ".Colory::rgbToHex($random_rgb)."\n";
$random_rgba = Colory::randomRgb(true);
echo "> RGB To HEX ($random_rgba[r], $random_rgba[g], $random_rgba[b], $random_rgba[a]) => ".json_encode(Colory::rgbToHex($random_rgba))."\n";
echo "> RGB To HEX (nabeghe/colory) => ".json_encode(Colory::rgbToHex('nabeghe/colory'))."\n";
echo "\n";

echo "[[ HEX To RGB ]]\n";
$random_hex = Colory::randomHex();
echo "> HEX To RGB ($random_hex) => ".json_encode(Colory::hexToRgb($random_hex))."\n";
$random_hexa = Colory::randomHex(true);
echo "> HEX To RGB ($random_hexa) => ".json_encode(Colory::hexToRgb($random_hexa))."\n";
echo "> HEX To RGB (nabeghe/colory) => ".json_encode(Colory::hexToRgb('nabeghe/colory'))."\n";
echo "\n";
```

📖 License
---------

[](#-license)

Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance46

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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

570d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dae1bf378bcf40fe55c193160377d613d628188587554a3fb11cdec6f0521ba1?d=identicon)[nabeghe](/maintainers/nabeghe)

---

Top Contributors

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

---

Tags

colorcolorsphpphp-colorphp-colorsphp-librariesphp-libraryhelperlibrarycolorsupportcolorycolor helpercolors helper

### Embed Badge

![Health badge](/badges/nabeghe-colory/health.svg)

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

PHPackages © 2026

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