Skip to content

Encapsulate version checking for view namespace hash#2551

Merged
calebporzio merged 2 commits intolivewire:mainfrom
ghabriel25:refactor/encapsulate-version-checking
Apr 7, 2026
Merged

Encapsulate version checking for view namespace hash#2551
calebporzio merged 2 commits intolivewire:mainfrom
ghabriel25:refactor/encapsulate-version-checking

Conversation

@ghabriel25
Copy link
Copy Markdown
Contributor

@ghabriel25 ghabriel25 commented Apr 7, 2026

The scenario

I noticed that the Laravel 12 view-namespace hashing change and was being checked in two separate places:

  • FluxManager.php

    flux/src/FluxManager.php

    Lines 177 to 185 in eea9531

    public function componentExists($name)
    {
    // Laravel 12+ uses xxh128 hashing for views https://github.com/laravel/framework/pull/52301...
    if (app()->version() >= 12) {
    return app('view')->exists(hash('xxh128', 'flux') . '::' . $name);
    }
    return app('view')->exists(md5('flux') . '::' . $name);
    }
  • FluxTagCompiler.php
    // Laravel 12+ uses xxh128 hashing for views https://github.com/laravel/framework/pull/52301...
    return "<?php if (!Flux::componentExists(\$name = {$component})) throw new \Exception(\"Flux component [{\$name}] does not exist.\"); ?>##BEGIN-COMPONENT-CLASS##@component('{$class}', 'flux::' . {$component}, [
    'view' => (app()->version() >= 12 ? hash('xxh128', 'flux') : md5('flux')) . '::' . {$component},
    'data' => \$__env->getCurrentComponentData(),
    ])
    <?php \$component->withAttributes(\$attributes->getAttributes()); ?>";
    }

The componentString() override in the FluxTagCompiler (for the internal flux::delegate-component forwarding mechanism)

This PR extracts the logic into a single getFluxHash() helper inside FluxManager and updates both locations to use it.

Changes

  • Added Flux::getFluxHash()
  • Updated componentExists() to reuse the helper
  • Updated the delegate-component path in componentString() so the hash is now resolved at compile time instead of emitting a runtime ternary on every request.

ghabriel25 and others added 2 commits April 7, 2026 10:06
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@calebporzio calebporzio merged commit 15f6f44 into livewire:main Apr 7, 2026
@ghabriel25 ghabriel25 deleted the refactor/encapsulate-version-checking branch April 7, 2026 13:38
@ghabriel25 ghabriel25 changed the title Encapsulate version checking for view hash Encapsulate version checking for view namespace hash Apr 8, 2026
joshhanley added a commit that referenced this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants