承接 ramazancetinkaya/color-code-converter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ramazancetinkaya/color-code-converter

Composer 安装命令:

composer require ramazancetinkaya/color-code-converter

包简介

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

README 文档

README

PHP Version Packagist Downloads License Stars 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 · New Pull Request

⭐ Show Your Support

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

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

Using Composer

You can install the ColorCode library using Composer. Run the following command in your terminal:

composer require ramazancetinkaya/color-code-converter

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

Here's how you can use the ColorConverter class:

<?php

require 'vendor/autoload.php';

use ramazancetinkaya\ColorConverter;

$converter = new ColorConverter();

// Convert HEX to RGB
$rgb = $converter->hexToRgb('#FF5733'); // [255, 87, 51]

# echo '<pre>' . print_r($rgb, true) . '</pre>';

// Convert RGB to HEX
$hex = $converter->rgbToHex([255, 87, 51]); // "#FF5733"

# echo $hex;

// Convert RGB to HSL
$hsl = $converter->rgbToHsl([255, 87, 51]); // [10.59, 100, 60]

# echo '<pre>' . print_r($hsl, true) . '</pre>';

// Convert HSL to RGB
$rgb2 = $converter->hslToRgb([14.29, 100, 60]); // [255, 100, 51]

# echo '<pre>' . print_r($rgb2, true) . '</pre>';

// Convert HEX to HSL
$hsl2 = $converter->hexToHsl('#FF5733'); // [10.59, 100, 60]

# echo '<pre>' . print_r($hsl2, true) . '</pre>';

// Convert HSL to HEX
$hex2 = $converter->hslToHex([14.29, 100, 60]); // "#FF5733"

# echo $hex2;

API Documentation

hexToRgb(string $hexColor): array

Converts a HEX color string to its RGB representation.

  • Parameters:
    • $hexColor (string): The HEX color string (e.g., "#FF5733", "FF5733").
  • Returns:
    • (array): An RGB array [R, G, B] with values between 0-255.

rgbToHex(array $rgbArray): string

Converts an RGB array to a HEX color string.

  • Parameters:
    • $rgbArray (array): An array [R, G, B] with values between 0-255.
  • Returns:
    • (string): The HEX color string (e.g., "#FF5733").

rgbToHsl(array $rgbArray): array

Converts an RGB array to its HSL representation.

  • Parameters:
    • $rgbArray (array): An array [R, G, B] with values between 0-255.
  • Returns:
    • (array): An HSL array [H, S, L] where:
      • H (Hue): 0-360
      • S (Saturation): 0-100 (%)
      • L (Lightness): 0-100 (%)

hslToRgb(array $hslArray): array

Converts an HSL array to its RGB representation.

  • Parameters:
    • $hslArray (array): An array [H, S, L] where:
      • H (Hue): 0-360
      • S (Saturation): 0-100 (%)
      • L (Lightness): 0-100 (%)
  • Returns:
    • (array): An RGB array [R, G, B] with values between 0-255.

Project Structure

src/
├── ColorConverter.php
composer.json
README.md
LICENSE

Security

This library is designed with security in mind. Input validation and error handling are implemented to prevent misuse. For vulnerabilities, please open an issue.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.

Authors

This project is maintained with ❤️ by:

License

This project is licensed under the MIT License. See the LICENSE file for more details.

ramazancetinkaya/color-code-converter 适用场景与选型建议

ramazancetinkaya/color-code-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.07k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2024 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「rgb」 「hsl」 「hex」 「web-development」 「php-library」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ramazancetinkaya/color-code-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ramazancetinkaya/color-code-converter 我们能提供哪些服务?
定制开发 / 二次开发

基于 ramazancetinkaya/color-code-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-30