Randomize only the hue while holding perceptual lightness and chroma steady:
use PhpColor\Color\Color;
$color = Color::oklch(
lightness: 0.65,
chroma: 0.15,
hue: random_int(0, 359),
);
echo $color->toHex();
use PhpColor\Color\Color;
$color = Color::oklch(
lightness: 0.65,
chroma: 0.15,
hue: random_int(0, 359),
);
echo $color->toHex();
This produces colors with a consistent visual weight. Random RGB bytes can cluster near black, white, or grey because they do not control perceived lightness or colorfulness.
Converting vivid OKLCH colors to sRGB can move an out-of-gamut value. If exact output matters, validate the final serialized color against the target gamut.