mischiefcollective/colorjizz
ColorJizz-PHP is a lightweight color library for converting and manipulating colors across formats like RGB, CMYK, Hex, HSV, CIELab/LCh, XYZ, and Yxy. Supports chaining operations (hue, saturation, greyscale) while keeping originals immutable.
Strengths:
Hex::fromString('red')->hue(-20)) improves readability and developer experience, especially in Laravel’s Blade templates or dynamic color generation logic.Gaps:
Color cast for database storage). This requires manual wiring.laravel-colorjizz) forces manual setup, increasing boilerplate.ThemeService that adjusts palette based on user preferences).Hex as a string but retrieving as RGB).spatie/laravel-colorjizz) to standardize integration (e.g., Blade helpers, Eloquent casts)?Color Eloquent cast for Hex/RGB/CMYK)?colorjs.io) suffice for frontend-only needs, reducing backend load?composer.json:
"require": {
"mischiefcollective/colorjizz": "^1.0"
}
// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->bind('colorjizz', function () {
return new MischiefCollective\ColorJizz\Autoloader();
});
}
// app/Providers/BladeServiceProvider.php
Blade::directive('color', function ($expression) {
return "<?php echo app('colorjizz')->evaluate({$expression}); ?>";
});
Usage:
<div style="background: @color('Hex::fromString(\'#FF5733\')->lightness(20)->toHex()')">
protected $casts = [
'hex_color' => 'colorjizz', // Custom cast
];
// app/Casts/ColorCast.php
public function getColorJizzAttribute($value)
{
return new Hex($value);
}
composer.json and autoload.// app/Services/ColorService.php
class ColorService {
public function manipulate(string $format, string $input, array $operations) {
$color = call_user_func([$format, 'fromString'], $input);
foreach ($operations as $method => $value) {
$color = $color->$method($value);
}
return $color->toString();
}
}
ColorService::getComplementaryPalette()).laravel-mix, spatie/array-to-xml).Hex/RGB in PHP).ProductService::adjustColorPalette()).Cache::remember()).busy queue for batch processing).How can I help you explore Laravel packages today?