ozdemirburak/iris
PHP color library for manipulation and conversion between Hex, Hexa, RGB, RGBA, HSL, HSLA, HSV, CMYK, and OKLCH. Requires PHP 8.1+ and supports named colors, alpha channels, and conversion methods.
lighten, darken, saturate, spin, mix, tint, shade, fade, fadeIn, fadeOut). This is exactly the server-side primitive needed for "derive a full palette from one brand color" features — a recurring request in white-label, multi-tenant, and theming roadmaps that is otherwise hand-rolled and reinvented per project.isLight()/isDark() supports automatic foreground/text contrast selection, which removes a common class of "unreadable button" support tickets and QA cycles.->gradient($colorB, $steps), multi-pivot). Enables data-visualization palettes, heatmaps, progress/severity scales, and generated design tokens — all server-side, all reproducible in tests. This is a recent, actively added capability (2025-12-05 changelog), which is a positive signal on roadmap alignment.Factory::init(). User-supplied color strings (from forms, imports, or a mixed DB column) get resolved to the correct type rather than throwing. That is a validation/normalization concern PMs usually end up paying for twice — once in the form layer, once in the render layer.toOklch() on every class means a "generate perceptually even palettes" feature is a configuration change, not a project.Adopt when:
Look elsewhere / build thin when:
isLight()/isDark() is a heuristic, not a WCAG verdict. Expect to add a contrast utility on top (or pair with a dedicated accessibility library) and say so upfront.oklch(from green l c h)) — documented as unsupported; alpha is silently ignored. Don't assume round-tripping preserves alpha through OKLCH.Adoption checklist before committing: pin an exact version in composer.json; confirm the PHP 8.1 floor matches your platform roadmap; write characterization tests for the specific conversions you depend on (alpha handling especially, given the recent breaking changes); and record the fallback plan (fork-and-own) in the technical decision record.
To executives: This is a small, free (MIT), low-risk library that unblocks a class of theming and branding features we'd otherwise build and maintain ourselves — per-customer color customization, automatically derived UI states, and chart palettes. It's a pure calculation library: no data storage, no external services, no security surface, so the compliance and privacy review is trivial. Total cost is roughly a day of integration plus a thin internal wrapper; the alternative is ad-hoc color math scattered across controllers and views, which is the more expensive option over time. The main caveat is maintenance depth (a single maintainer, limited adoption), which we mitigate by pinning the version and keeping our wrapper thin enough to fork if needed — a small, bounded risk for a dependency this narrow.
To engineering: Adopt ozdemirburak/iris behind a single internal service class rather than calling it directly from controllers or Blade. It gives us tested conversions across nine color spaces (including OKLCH, which we want for future palette work), a Factory that normalizes unpredictable user input, and the manipulation primitives (lighten, mix, gradient, fade) we keep reimplementing. Constraints to design around: PHP 8.1+ minimum, no Laravel service provider or validation rule (we write both), no WCAG contrast calculation (we add one if accessibility is in scope), and OKLCH ignores alpha. Recent releases were breaking (PHP 8.1 floor, PHPUnit 10/11, alpha-preservation fixes), so pin the version and cover our specific conversions with tests before upgrading.
Bottom line: buy the conversion math, build the design policy, and wrap the dependency so the decision stays reversible.
How can I help you explore Laravel packages today?