Download the PHP package daikazu/laratone without Composer
On this page you can find all versions of the php package daikazu/laratone. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daikazu/laratone
More information about daikazu/laratone
Files in daikazu/laratone
Package laratone
Short Description Simple API for managing color libraries in you Laravel application.
License MIT
Homepage https://github.com/daikazu/laratone
Informations about the package laratone
Laratone
Laratone is a comprehensive Laravel package for managing color libraries and swatches in your applications. It provides an easy-to-use API for storing, retrieving, and managing color data, with built-in support for various color formats (HEX, RGB, CMYK, LAB, OKLCH) and popular color libraries.
Features
- Multiple built-in color libraries (Solid Coated, GuangShun Thread, HC Twill)
- Auto-calculation of RGB, CMYK, LAB, and OKLCH from hex values
- Find closest matching colors using LAB or OKLCH distance algorithms
- Configurable white point reference for LAB color calculations
- Automatic color data caching with configurable TTL
- Easy color book management and seeding
- Flexible REST API with filtering, sorting, and pagination
- Type-safe color value casting (LAB, RGB, CMYK, OKLCH)
- Full PHP 8.4 support with strict typing throughout
Requirements
- PHP 8.4 or higher
- Laravel 12.x or greater
Note: For PHP 8.3 / Laravel 11 support, use version 4.x of this package.
Installation
You can install the package via composer:
Publish Configuration and Migrations
Publish the configuration file:
Publish and run the migrations:
Configuration
The published config file (config/laratone.php) contains the following options:
White Point Options
When RGB, CMYK, LAB, or OKLCH values are not provided, they are automatically calculated from the hex value. LAB calculations require a reference white point (illuminant). OKLCH is a perceptually uniform color space and does not require white point configuration.
| Value | Description | Use Case |
|---|---|---|
D50 |
Warm white (~5000K) | Print/graphic arts |
D55 |
Mid-morning daylight (~5500K) | Photography |
D65 |
Standard daylight (~6500K) | Default, web/screen |
D75 |
North sky daylight (~7500K) | Scientific applications |
Usage
Seeding Color Books
Laratone comes with several pre-built color libraries:
ColorBookPlusSolidCoatedColorBookPlusSolidCoated336NewColorsColorBookMetallicCoatedColorBookPlusMetallicCoatedGuangShunThreadColorsHCTwillColors
Seed All Color Books
Seed Specific Color Books
Import Custom Color Books
Example Color Book format:
Note: Only
nameandhexare required. RGB, CMYK, LAB, and OKLCH values are optional and will be auto-calculated from hex if not provided. If you have official color values (e.g., Solid Coated LAB values), include them to use those instead of calculated values.
REST API
Color Books
List all available color books:
| Parameter | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort by name (asc/desc) | - |
Colors
Get colors from a specific color book:
| Parameter | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort by name (asc/desc) | - |
| limit | No | Limit number of results | - |
| random | No | Randomize results (1/true) | false |
Note: When using
random=true, results are not cached to ensure different results on each request.
Find Closest Colors
Find the closest matching colors in a color book to a target color:
| Parameter | Required | Description | Default |
|---|---|---|---|
| hex | Yes | Target color (6-char hex, with or without #) | - |
| limit | No | Number of closest colors to return | 1 |
| algorithm | No | Distance algorithm: lab or oklch |
lab |
Example Request:
Example Response:
Distance Algorithms
| Algorithm | Description | Best For |
|---|---|---|
lab |
CIE76 Delta E in LAB color space | General color matching, industry standard |
oklch |
Perceptually uniform cylindrical distance | Modern applications, consistent perception |
Rate Limiting & Custom Middleware
Laratone routes use a laratone middleware alias that does nothing by default. You can replace it with your own middleware to add rate limiting, authentication, or other functionality.
To add rate limiting, define the laratone middleware alias in your application's bootstrap:
Or in a service provider:
You can create a custom middleware class that combines multiple behaviors:
Programmatic Usage
Laratone provides a simple API for managing colors programmatically:
Working with Color Models
Color values are automatically cast to associative arrays when accessed. If a value wasn't stored in the database, it will be automatically calculated from the hex value:
Auto-Calculation Behavior
- Hex is required - All colors must have a hex value
- Other values are optional - RGB, CMYK, LAB, and OKLCH are calculated from hex if not provided
- Stored values take precedence - If you provide explicit values (e.g., official Solid Coated LAB), those are used instead of calculated values
- LAB uses white point config - Calculated LAB values use the
white_pointsetting from your config - OKLCH is perceptually uniform - OKLCH does not require white point configuration and provides consistent perceptual color representation
Caching
Laratone automatically caches color book and color data to improve performance. The cache works with any Laravel cache driver, including file, database, Redis, and Memcached.
Cache is automatically cleared when:
- Creating a new color book
- Adding, updating, or deleting colors
To manually clear the cache:
Or programmatically:
Upgrading
See UPGRADE.md for upgrade instructions between major versions.
Testing
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Mike Wall
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laratone with dependencies
spatie/laravel-package-tools Version ^1.19
illuminate/contracts Version ^12.0