PHPackages                             gubler/color - 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. gubler/color

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

gubler/color
============

Color conversion library

v2.0.0(2y ago)0920↓100%1MITPHPPHP ^8.1CI failing

Since Jan 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/gubler/color)[ Packagist](https://packagist.org/packages/gubler/color)[ Docs](https://github.com/gubler/color)[ RSS](/packages/gubler-color/feed)WikiDiscussions master Synced 2mo ago

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

Gubler/Color
============

[](#gublercolor)

Color is a CSS color object library. It allows you to create a `Color` object and get multiple CSS color styles from it.

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

[](#installation)

Install the library with composer:

```
composer require gulber/color
```

Usage
-----

[](#usage)

Create a new `Color` object with a valid CSS color value:

```
// with hex value
$color = new Color('#F4E204');
// with short hex value
$color = new Color('#ccc');
// with RGB
$color = new Color('rgb(10, 20, 30)');
// with RGBA
$color = new Color('rgba(10, 20, 30, 0.5)');
// with HSL
$color = new Color('hsl(30.5, 100%, 50%)');
// with HSLA
$color = new Color('hsla(30.5, 100%, 50%, 1.0)');
```

Once you have created a color, you can export it in another format:

```
$color = new Color('#F4E204');
$color->rgba();
$color->hsla();
$color->hex();
```

You can also update the color:

```
$color->setHex('#fff000');
$color->setRgba(120, 0, 75, 0.9);
$color->setHsla(50.5, 70, 60, 1);
```

### Contrast Color Text

[](#contrast-color-text)

You can call `contrastTextColor` to get a new `Color` object, either black or white, whichever has better contrast with the parent `Color`.

```
$textColor = $color->contractTextColor();
$textColor->rgba() // either rgba(0, 0, 0, 1) or rgba(255, 255, 255, 1)
```

Thanks
------

[](#thanks)

This library was heavily inspired by [spatie/color](https://github.com/spatie/color).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

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

Total

3

Last Release

1008d ago

Major Versions

v0.5.0 → v1.0.02021-06-22

v1.0.0 → v2.0.02023-08-11

PHP version history (3 changes)v0.5.0PHP ^7.0

v1.0.0PHP ^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

conversioncolorrgb

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gubler-color/health.svg)

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

###  Alternatives

[spatie/color

A little library to handle color conversions

38018.9M28](/packages/spatie-color)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.1M10](/packages/ssnepenthe-color-utils)[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[mexitek/phpcolors

A series of methods that let you manipulate colors. Just incase you ever need different shades of one color on the fly.

5003.6M18](/packages/mexitek-phpcolors)[php-units-of-measure/php-units-of-measure

A PHP library for converting between standard units of measure.

3123.4M20](/packages/php-units-of-measure-php-units-of-measure)

PHPackages © 2026

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