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) and popular color libraries.
- 🎨 Multiple built-in color libraries (Pantone, GuangShun Thread, HC Twill)
- 🔄 Automatic color data caching for improved performance
- 📦 Easy color book management and seeding
- 🔍 Flexible API for color searching and filtering
- 🛠️ Simple integration with Laravel applications
- 📝 Support for custom color books and formats
- PHP 8.3 or higher
- Laravel 11.x or greater
You can install the package via composer:
composer require daikazu/laratonePublish the configuration file:
php artisan vendor:publish --tag="laratone-config"Publish and run the migrations:
php artisan vendor:publish --tag="laratone-migrations"
php artisan migrateThe published config file (config/laratone.php) contains the following options:
return [
// Table prefix for Laratone tables
'table_prefix' => 'laratone_',
// Cache duration in seconds for color books and colors
'cache_time' => 3600,
];Laratone comes with several pre-built color libraries:
ColorBookPlusSolidCoatedColorBookPlusSolidCoated336NewColorsColorBookMetallicCoatedColorBookPlusMetallicCoatedGuangShunThreadColorsHCTwillColors
php artisan laratone:seedphp artisan laratone:seed ColorBookPlusSolidCoatedSeederphp artisan laratone:seed --file ./mycolorbookfile.jsonExample Color Book format:
{
"name": "My Custom Color Book",
"data": [
{
"name": "Custom Color 1",
"lab": "88.19,-6.97,111.73",
"hex": "FEDD00",
"rgb": "254,221,0",
"cmyk": "0,1,100,0"
}
]
}List all available color books:
GET /api/laratone/colorbooks| Parameter | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort by name (asc/desc) | asc |
Get colors from a specific color book:
GET /api/laratone/colorbook/{color-book-slug}| Parameter | Required | Description | Default |
|---|---|---|---|
| sort | No | Sort by name (asc/desc) | asc |
| limit | No | Limit number of results | - |
| random | No | Randomize results | false |
Laratone provides a simple API for managing colors programmatically:
use Daikazu\Laratone\Laratone;
// Get all color books
$colorBooks = Laratone::colorBooks();
// Get a specific color book
$colorBook = Laratone::colorBookBySlug('color-book-plus-solid-coated');
// Create a new color book
$newColorBook = Laratone::createColorBook('My New Color Book');
// Add colors to a color book
$color = Laratone::addColorToBook($colorBook, [
'name' => 'New Color',
'hex' => 'FF0000',
'rgb' => '255,0,0'
]);
// Update a color
Laratone::updateColor($color, ['name' => 'Updated Color Name']);
// Delete a color
Laratone::deleteColor($color);Laratone automatically caches color book and color data to improve performance. The cache duration can be configured in the config file. To clear the cache:
Laratone::clearCache();composer testPlease see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.