phpcolor.dev is live. The library had a README; it now has a place to read the documentation, look colors up, try the API without installing anything, and check what a palette does to someone who does not see red.
What is on it
- Documentation. Getting Started for the first color, a guide organized by decision rather than by class name, and 35 recipes that each answer one task.
- API reference for the 85 classes, interfaces and enums, generated from the source so it cannot drift from the code.
- A color catalog: 101 named colors, 72 palettes and 72 gradients, each with its OKLCH coordinates, contrast figures and harmonies.
- Eight tools that run in the browser: contrast checker, converter, palette generator, harmonies, gamut inspector, relative colors, color names and vision simulation.
- Thirteen color space pages, each with what the space is for and where it stops being the right choice.
PHP that runs in your browser
The playground is not a snippet renderer. It compiles PHP 8.4 to WebAssembly, mounts the PHPColor source tree into it, and runs your code client-side. Nothing is sent to a server, because there is no server involved in the execution.
$blue = Color::parse("#3b82f6");
Playground::debug($blue);
// swatch, hex, OKLCH, luminance, contrast against white and black
$blue = Color::parse("#3b82f6");
Playground::debug($blue);
// swatch, hex, OKLCH, luminance, contrast against white and black
Eight examples are ready to open, from parsing to vision simulation, and each one is editable. Changes go into the URL, so a broken color is something you can send to someone else.
Every number here was executed
Documentation drifts from code quietly. The counts, hex values and contrast figures on this site are produced by running the installed version of the library and comparing the output to what the page claims, not by trusting a sentence written six months ago.
That has a consequence worth stating plainly: where the library is limited, the
site says so. Round trips through a wider gamut are not exact. transparent is
not a parseable color in 1.0. HSL is a notation, not a color space. Those belong
in the documentation as much as the features do.