PHPackages                             lasserafn/php-hexer - 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. lasserafn/php-hexer

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

lasserafn/php-hexer
===================

A package to adjust brightness from a hex colorcode

v1.10(3y ago)61.2k1MITPHPPHP ^5.6|^7.0|^8.0

Since Jun 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/LasseRafn/php-hexer)[ Packagist](https://packagist.org/packages/lasserafn/php-hexer)[ RSS](/packages/lasserafn-php-hexer/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (2)Versions (8)Used By (0)

HEX color modifier — brightness, conversion and more.
=====================================================

[](#hex-color-modifier--brightness-conversion-and-more)

Ever wanted to lighten or darken a hex in PHP? This package will allow you to. It's easy to use, fully tested and is very lightweight.

**+ Added the ability to convert to RGB**

 [![Build Status](https://camo.githubusercontent.com/5a001628b89db1fa7afd392154cf6d8b2bce37dd64d0f7da6014ffad260fc6bd/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4c617373655261666e2f7068702d68657865722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/LasseRafn/php-hexer)[![Coverage](https://camo.githubusercontent.com/7d09848e82951854af2bb1fdb24236803ed1c0b1fb0ba737ad5b4e2e4ba408f8/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f4c617373655261666e2f7068702d68657865722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/LasseRafn/php-hexer)[![StyleCI Status](https://camo.githubusercontent.com/249d33e961745bfd8e09f8e375aa8c62b6e4141033e772a60308053ded422958/68747470733a2f2f7374796c6563692e696f2f7265706f732f39343532373133372f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/94527137)[![Total Downloads](https://camo.githubusercontent.com/a73c51f9fbd410375df3f3857f25b846fe5d8c8c84dccd5de93d84bf038b2522/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c617373657261666e2f7068702d68657865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lasserafn/php-hexer)[![Latest Stable Version](https://camo.githubusercontent.com/52ab8db3381fa523a7d377a04a8499dd92d2118deda566a81f209755bf1d6afb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c617373657261666e2f7068702d68657865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lasserafn/php-hexer)[![License](https://camo.githubusercontent.com/5fb8605851ce4f83745b50232ca8566cd5e6ac2fbbac7dc6312f2ec0904452f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c617373657261666e2f7068702d68657865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lasserafn/php-hexer)

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

[](#installation)

You just require using composer and you're good to go!

```
composer require lasserafn/php-hexer
```

Usage
-----

[](#usage)

As with installation, usage is quite simple.

```
use LasseRafn\Hexer\Hex;

// Lighten
$hex = new Hex('#333'); // You can leave out the hashtag if you wish.
echo $hex->lighten(15); // Output: #595959 (if you left out the hashtag, it would not be included in the output either)

// Darken
$hex = new Hex('ffffff');
echo $hex->darken(15); // Output: d9d9d9

// To RGB
$hex = new Hex('007F00');
$hex->lighten(50)->toRgb(); // Returns: ['r' => 128, 'g' => 255, 'b' => 128]
```

Methods
-------

[](#methods)

The constructor accepts one parameter (`hex`) which can optionally contain a hashtag (#). The length has to be between 3-6 characters (without the hashtag).

### `lighten($percentage)`

[](#lightenpercentage)

Will lighten the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise.

### `darken($percentage)`

[](#darkenpercentage)

Will darken the color by X percentage. Percentage must be between 0-100. An exception will be thrown otherwise.

### `toRgb()`

[](#torgb)

Will return the hex as RGB (an array of `r`, `g`, `b`).

Exceptions
----------

[](#exceptions)

If you input a HEX which is less than 3 characters of length, or greater than 6, an exception will be thrown. Similar with percentages, if you specify a percentage less than zero, or greater than 100, an exception will be thrown. If the percentage *is* zero, the hex itself will simply be returned.

Requirements
------------

[](#requirements)

- PHP 5.6, 7.0 or 7.1

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~487 days

Total

5

Last Release

1308d ago

Major Versions

v0.8 → v1.02017-06-16

PHP version history (2 changes)v0.8PHP ^5.6|^7.0|^7.1

v1.10PHP ^5.6|^7.0|^8.0

### Community

Maintainers

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

---

Top Contributors

[![LasseRafn](https://avatars.githubusercontent.com/u/2689341?v=4)](https://github.com/LasseRafn "LasseRafn (23 commits)")[![davejtoews](https://avatars.githubusercontent.com/u/9664035?v=4)](https://github.com/davejtoews "davejtoews (1 commits)")

---

Tags

brightnesscolordarkenhexlightenphpphpcolorhexBrightness

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lasserafn-php-hexer/health.svg)

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

###  Alternatives

[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.1M10](/packages/ssnepenthe-color-utils)[fjw/color-compare

A library for converting colors (Hex, RGB, HSL, CIELAB (LAB), DIN-99) and calculating color distances based on DIN-99.

1310.0k](/packages/fjw-color-compare)

PHPackages © 2026

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