PHPackages                             ramazancetinkaya/color-code-converter - 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. ramazancetinkaya/color-code-converter

ActiveLibrary

ramazancetinkaya/color-code-converter
=====================================

A modern PHP library for converting color codes between RGB, HEX, and HSL color spaces.

1.0.0(1y ago)52.4k↓46.9%MITPHPPHP &gt;=8.0

Since Dec 30Pushed 1y ago2 watchersCompare

[ Source](https://github.com/ramazancetinkaya/color-code-converter)[ Packagist](https://packagist.org/packages/ramazancetinkaya/color-code-converter)[ Docs](https://github.com/ramazancetinkaya/color-code-converter)[ RSS](/packages/ramazancetinkaya-color-code-converter/feed)WikiDiscussions main Synced 1mo ago

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

Color Code Converter
====================

[](#color-code-converter)

[![PHP Version](https://camo.githubusercontent.com/14639c17ca36d5516bab07357840361ab57c5258fb0f110ae9cefb75611b59b3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d3737376262343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/14639c17ca36d5516bab07357840361ab57c5258fb0f110ae9cefb75611b59b3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532422d3737376262343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![Packagist](https://camo.githubusercontent.com/68f65e7006e136fa706f403f0f47fee47c8e7da02cf725f568d81bc6b1b0796c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72616d617a616e636574696e6b6179612f636f6c6f722d636f64652d636f6e7665727465723f7374796c653d666f722d7468652d626164676526636f6c6f723d333443373539)](https://packagist.org/packages/ramazancetinkaya/color-code-converter)[![Downloads](https://camo.githubusercontent.com/ae1da3f340e049a79c1a19f807ac5d3df9d1ca00be9f5f761a118abfb57b7472/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72616d617a616e636574696e6b6179612f636f6c6f722d636f64652d636f6e7665727465723f7374796c653d666f722d7468652d626164676526636f6c6f723d6f72616e6765)](https://camo.githubusercontent.com/ae1da3f340e049a79c1a19f807ac5d3df9d1ca00be9f5f761a118abfb57b7472/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72616d617a616e636574696e6b6179612f636f6c6f722d636f64652d636f6e7665727465723f7374796c653d666f722d7468652d626164676526636f6c6f723d6f72616e6765)[![License](https://camo.githubusercontent.com/4ee85824611af0644848637137fbd9c74da9b617f54ab2415cd519bb539a60bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e2d736f757263652d696e6974696174697665266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/4ee85824611af0644848637137fbd9c74da9b617f54ab2415cd519bb539a60bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d6f70656e2d736f757263652d696e6974696174697665266c6f676f436f6c6f723d7768697465)[![Stars](https://camo.githubusercontent.com/7002917f36b05f4c0ef42c4d800f67868cec1f0ee1776f23c09d0cd5f28b69ea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f72616d617a616e636574696e6b6179612f636f6c6f722d636f64652d636f6e7665727465723f7374796c653d666f722d7468652d626164676526636f6c6f723d464144303245266c6f676f3d676974687562)](https://github.com/ramazancetinkaya/color-code-converter/stargazers)[![Issues](https://camo.githubusercontent.com/2eca8c074a19cc625dba878030248fcddada63229c154e99ba4839f463353992/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f72616d617a616e636574696e6b6179612f636f6c6f722d636f64652d636f6e7665727465723f7374796c653d666f722d7468652d626164676526636f6c6f723d453434303546266c6f676f3d676974687562)](https://github.com/ramazancetinkaya/color-code-converter/issues)

A **powerful, modern, and extensible PHP library** for converting color codes between various color spaces, such as **RGB**, **HEX**, and **HSL**. Designed with a focus on readability, scalability, and production readiness, this library is the ultimate solution for color manipulation.

[Report a Bug](https://github.com/ramazancetinkaya/color-code-converter/issues)· [New Pull Request](https://github.com/ramazancetinkaya/color-code-converter/pulls)

### ⭐ Show Your Support

[](#-show-your-support)

If you like this project, give it a ⭐ and share it with your network!

---

Features
--------

[](#features)

✨ **Versatile Color Conversions**
Effortlessly convert color codes between popular formats:

- 🔄 **RGB ↔ HEX**
- 🔄 **RGB ↔ HSL**
- 🔄 **HEX ↔ HSL**

⚡ **Modern PHP Standards**
Built with PHP 8+ features for high performance and future-proof compatibility:

- 🏷️ Strict typing (`strict_types=1`)
- 🛠️ Fully typed methods

🛡️ **Robust Error Handling**

- 🔍 Input validation with detailed exceptions
- 🛑 Catch invalid formats before they propagate

🧩 **Extensible Architecture**

- 📦 Add support for additional color spaces (e.g., CMYK, LAB) with ease
- 🏗️ Modular design for seamless integration

📘 **Comprehensive Documentation**

- 📝 Fully documented methods with standardized PHPDoc comments
- 📚 Clear usage examples

🌐 **Production-Ready**

- 🔒 Secure and reliable for real-world applications
- ⚙️ Optimized for maintainability and scalability

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

[](#installation)

### Using Composer

[](#using-composer)

You can install the `ColorCode` library using [Composer](https://getcomposer.org/). Run the following command in your terminal:

```
composer require ramazancetinkaya/color-code-converter
```

### Manual Installation

[](#manual-installation)

Alternatively, download the source code and include it in your project manually.

1. Clone the repository: ```
    git clone https://github.com/ramazancetinkaya/color-code-converter.git
    ```
2. Include the library in your project: ```
    require 'path/to/ColorConverter.php';
    ```

Usage
-----

[](#usage)

Here's how you can use the `ColorConverter` class:

```
