PHPackages                             devlop/colours - 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. devlop/colours

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

devlop/colours
==============

Collection of color classes to simplify working and converting colors in PHP.

v1.0.2(1y ago)141MITPHPPHP ^7.4|^8.0

Since Sep 13Pushed 1y ago1 watchersCompare

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

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

 [![Latest Stable Version](https://camo.githubusercontent.com/897f310e7cce32fdd1b547e2ec75a759f070fd190469c9649c6339609788cec1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465766c6f702f636f6c6f757273)](https://packagist.org/packages/devlop/colours) [![License](https://camo.githubusercontent.com/6e5481e0d1986665fabee7846000a4efbaa697eef343599567f5bddd4ea13a94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465766c6f702f636f6c6f757273)](https://github.com/devlop/colours/blob/master/LICENSE.md)

Colours
=======

[](#colours)

Collection of color classes to simplify working with and converting colors in PHP.

Installation
============

[](#installation)

```
composer require devlop/colours
```

Usage
=====

[](#usage)

HexColor
--------

[](#hexcolor)

```
use Devlop\Colours\HexColor;

// check validity
HexColor::isValid('#fff'); // bool(true)
HexColor::isValid('#0B33B1'); // bool(true)
HexColor::isValid('#19b9cd'); // bool(true)
HexColor::isValid('#b9cd'); // bool(false)
HexColor::isValid('red'); // bool(false)
HexColor::isValid('19b9cd'); // bool(true)

// check validity (strict mode)
HexColor::isValid('19b9cd', true); // bool(false)

// creating from hex string
$hexColor = new HexColor('#f0f');

// creating from other formats
$hexColor = HexColor::fromHslColor($hslColorInstance);
$hexColor = HexColor::fromRgbColor($rgbColorInstance);
$hexColor = HexColor::fromCmykColor($cmykColorInstance);

// get the hex string
$hexColor->getHexString(); // string('#ff00ff')

// converting to other formats
$hslColor = $hexColor->toHsl();
$rgbColor = $hexColor->toRgb();
$cmykColor = $hexColor->toCmyk();
```

HslColor
--------

[](#hslcolor)

```
use Devlop\Colours\HslColor;

// creating from HSL values
$hslColor = new HslColor(180, 96, 77);

// creating from other formats
$hslColor = HslColor::fromHexString('#b187F5');
$hslColor = HslColor::fromHexColor($hexColorInstance);
$hslColor = HslColor::fromRgbColor($rgbColorInstance);

// get HSL properties
$hslColor->getHue(); // int(180)
$hslColor->getSaturation(); // int(96)
$hslColor->getLightness(); // int(77)

// converting to other formats
$hexColor = $hslColor->toHex();
$rgbColor = $hslColor->toRgb();
```

RgbColor
--------

[](#rgbcolor)

```
use Devlop\Colours\RgbColor;

// creating from RGB values
$rgbColor = new RgbColor(221, 186, 146);

// creating from other formats
$rgbColor = RgbColor::fromHexString('#f3840c');
$rgbColor = RgbColor::fromHexColor($hexColorInstance);
$rgbColor = RgbColor::fromHslColor($hslColorInstance);
$rgbColor = RgbColor::fromCmykColor($cmykColorInstance);

// get RGB properties
$rgbColor->getRed(); // int(221)
$rgbColor->getGreen(); // int(186)
$rgbColor->getBlue(); // int(146)

// converting to other formats
$hexColor = $rgbColor->toHex();
$hslColor = $rgbColor->toHsl();
$cmykColor = $rgbColor->toCmyk();
```

CmykColor
---------

[](#cmykcolor)

```
use Devlop\Colours\CmykColor;

// creating from CMYK values
$cmykColor = new CmykColor(20, 80, 65, 34);

// creating from other formats
$cmykColor = CmykColor::fromHexString('#f3840c');
$cmykColor = CmykColor::fromHexColor($hexColorInstance);
$cmykColor = CmykColor::fromRgbColor($rgbColorInstance);

// get CMYK properties
$cmykColor->getCyan(); // int(20)
$cmykColor->getMagenta(); // int(80)
$cmykColor->getYellow(); // int(65)
$cmykColor->getKey(); // int(34)

// converting to other formats
$hexColor = $cmykColor->toHex();
$rgbColor = $cmykColor->toRgb();
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Total

3

Last Release

690d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/devlop-colours/health.svg)

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k234.7M20.6k](/packages/friendsofphp-php-cs-fixer)[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[jmikola/geojson

GeoJSON implementation for PHP

3109.0M77](/packages/jmikola-geojson)

PHPackages © 2026

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