Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Iris Laravel Package

ozdemirburak/iris

Iris is a PHP 8.1+ color library for parsing, manipulating, and converting colors across Hex/Hexa, RGB/RGBA, HSL/HSLA, HSV, CMYK, and OKLCH. Provides format classes with channel accessors and easy toX() conversions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Modular Design: Iris is a lightweight, self-contained library with no external dependencies (beyond PHP 8.1+), making it easy to integrate into Laravel applications without bloating the dependency tree.
  • Color-Specific Classes: The package follows a class-per-format approach (Hex, Hsl, Rgb, etc.), which aligns well with Laravel’s single-responsibility principle and type safety (PHP 8.1+).
  • Immutable Operations: Methods like toHex(), saturate(), and mix() return new instances rather than modifying state, which is functional and thread-safe—ideal for Laravel’s request/response lifecycle.
  • Factory Pattern: The Factory::init() method abstracts color parsing, reducing boilerplate when dealing with dynamic color inputs (e.g., user uploads or database fields).

Integration Feasibility

  • Laravel Compatibility:
    • PHP 8.1+: Fully compatible with Laravel 9+ (LTS) and Laravel 10+.
    • No Framework Lock-in: Pure PHP with no Laravel-specific dependencies, but integrates seamlessly with:
      • Blade Templates: For dynamic color generation (e.g., UI themes, gradients).
      • Eloquent Models: For storing/validating color fields (e.g., hex, hsl).
      • API Responses: For returning color-manipulated data (e.g., image processing endpoints).
    • Service Container: Can be registered as a singleton or bound to interfaces for dependency injection.
  • Database Integration:
    • Supports storing colors in normalized formats (e.g., hex, rgb) and converting them on-the-fly.
    • Example: Store hsl(120,100%,50%) in a theme_color column and convert to hex for frontend use.
  • Asset Pipeline:
    • Generate CSS variables or inline styles dynamically (e.g., @media (prefers-color-scheme: dark) { --primary: {{ $color->darken(20)->toHex() }} }).

Technical Risk

Risk Area Assessment Mitigation Strategy
Performance Color conversions are O(1) but may introduce overhead in loops. Benchmark critical paths (e.g., gradient generation for 100+ colors). Cache results if reused.
Precision Loss CMYK/RGB conversions may round values (fixed in v4.1.1). Test edge cases (e.g., cmyk(0,0,0,100)#000000). Use Oklch for perceptual uniformity.
Alpha Handling Alpha precision varies across formats (e.g., Hexa vs. Hsla). Standardize on float for internal alpha calculations; document expected inputs.
Backward Compatibility Breaking changes in v4.x (PHP 8.1+, PHPUnit 10/11). Pin to ^4.0 in composer.json if migrating from older Laravel/PHP versions.
OKLCH Support Experimental/less common than RGB/HSL. Use only for advanced use cases (e.g., accessibility tools). Fall back to HSL for broad compatibility.

Key Questions

  1. Use Case Prioritization:
    • Will Iris replace existing color logic (e.g., custom Color class) or augment it (e.g., for OKLCH/gradient features)?
    • Example: If your app uses CSS variables, Iris can generate them dynamically; if you need CMYK for print, test conversion accuracy.
  2. Data Storage:
    • Should colors be stored in normalized formats (e.g., hex) or user-friendly formats (e.g., hsl(120,100%,50%))?
    • Iris supports both but may need validation rules (e.g., Laravel’s Illuminate\Validation\Rule).
  3. Performance:
    • For high-throughput systems (e.g., batch image processing), profile gradient/mix operations.
  4. Testing:
    • Does your app need color accessibility validation (e.g., WCAG contrast)? Iris’s isLight()/isDark() methods can help.
  5. Future-Proofing:
    • Monitor for updates (e.g., oklch() alpha support, new color spaces like lch()).

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Blade: Dynamically generate color-manipulated styles.
      <div style="background: {{ $themeColor->toHex() }}">{{ $themeColor->lighten(10)->toHex() }}</div>
      
    • Eloquent: Add color fields to models with accessors/mutators.
      public function getHexAttribute(): string
      {
          return $this->attributes['hsl'] ? (new Hsl($this->hsl))->toHex() : '#000';
      }
      
    • APIs: Return color objects as JSON or convert to arrays.
      return response()->json(['gradient' => (new Hex('#ff0000'))->gradient(new Hex('#00ff00'), 5)]);
      
    • Queues: Process color-heavy tasks (e.g., batch image recoloring) asynchronously.
  • Frontend:
    • Tailwind CSS: Generate dynamic color palettes.
    • JavaScript Interop: Expose Iris methods via Laravel Mix/Webpack if needed (though JS libraries like color.js may suffice).

Migration Path

  1. Assessment Phase:
    • Audit existing color logic (e.g., regex-based hex parsing, manual RGB calculations).
    • Identify pain points (e.g., CMYK support, gradient generation).
  2. Pilot Integration:
    • Replace one color-heavy component (e.g., theme selector) with Iris.
    • Test edge cases (e.g., invalid inputs, alpha handling).
  3. Incremental Rollout:
    • Phase 1: Replace simple conversions (e.g., hexrgb).
    • Phase 2: Adopt advanced features (e.g., gradients, OKLCH).
    • Phase 3: Migrate data storage to normalized formats (if applicable).
  4. Deprecation:
    • Phase out custom color logic via feature flags or deprecated methods.

Compatibility

Component Compatibility Notes
Laravel 9/10 Full support (PHP 8.1+).
Laravel 8 Possible with PHP 8.0 polyfills, but test Oklch/gradient methods.
PHP 8.0 Works but lacks type safety (e.g., no return type hints).
Databases Store colors as string (e.g., hex, hsl) or json (for complex objects).
Caching Cache converted colors (e.g., Redis) if generated repeatedly (e.g., UI themes).
Testing Use PHPUnit to validate conversions (Iris includes tests as a reference).

Sequencing

  1. Core Integration:
    • Install via Composer: composer require ozdemirburak/iris.
    • Register a facade or service provider for global access:
      // app/Providers/AppServiceProvider.php
      public function boot()
      {
          app()->singleton('color', fn() => new Factory());
      }
      
  2. Validation:
    • Add Laravel validation rules for color formats:
      use Illuminate\Validation\Rule;
      
      Rule::define('hex', fn ($attribute, $value, $fail) => (new Hex($value)) instanceof Hex || $fail('Invalid hex color.'));
      
  3. Blade Directives:
    • Create helpers for common operations:
      // app/Helpers/ColorHelper.php
      if (!function_exists('color')) {
          function color(string $input): OzdemirBurak\Iris\Color\BaseColor
          {
              return Factory::init($input);
          }
      }
      
  4. Database:
    • Add accessors/mutators to Eloquent models (see above).
  5. Advanced Features:
    • Implement gradient generation for UI components (e.g., progress bars).
    • Use OKLCH for accessibility tools (e.g., contrast checkers).

Operational Impact

Maintenance

  • Pros:
    • MIT License: No vendor lock-in; community-driven updates.
    • Active Development: Recent releases (2026) with clear changelog.
    • Minimal Boilerplate: No complex setup; drop-in usage.
  • Cons:
    • No Laravel-Specific Docs: Requires inference for Eloquent/Blade use
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
cadot.eu/make
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky