Skip to content

Fix components compiling again after view:cache - #2856

Merged
ganyicz merged 2 commits into
livewire:mainfrom
fgilio:register-views-at-their-real-path
Oct 26, 2026
Merged

ganyicz merged 2 commits into
livewire:mainfrom
fgilio:register-views-at-their-real-path

Conversation

@fgilio

@fgilio fgilio commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The scenario

Right after php artisan view:cache (or optimize), Flux components still compile on the first request that renders them, on every deploy and on every new instance started from that build.

On a fresh app with livewire/flux, run php artisan view:cache, then:

$path = collect(Blade::getAnonymousComponentPaths())->firstWhere('prefix', 'flux')['path'].'/button/index.blade.php';

file_exists(Blade::getCompiledPath($path)); // false

The problem

Flux registers its components through a path with .. in it:

Blade::anonymousComponentPath(__DIR__.'/../stubs/resources/views/flux', 'flux');

Blade names a compiled view after the path the finder returns, and view:cache compiles each file at its real path. So <flux:button> resolves to .../flux/src/../stubs/resources/views/flux/button/index.blade.php, which maps to a different compiled file than the one view:cache wrote, and Blade (or Blaze) compiles it again. On a read-only filesystem, those requests fail.

The solution

Register the same directory without the ..:

Blade::anonymousComponentPath(dirname(__DIR__).'/stubs/resources/views/flux', 'flux');

__DIR__ is already a real path, so this matches what realpath() would return without a filesystem call. On a fresh app, rendering five Flux components right after view:cache compiled 8 Flux views at runtime before this change, and none after.

The general fix is laravel/framework#62005, which runs namespace hints through realpath() like view locations. It only reaches Laravel 13, so this one covers apps on 10, 11 and 12.

FluxProServiceProvider registers its path the same way, so Pro components need the same one-line change.

🤖 Generated with Claude Code

https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv

@fgilio fgilio changed the title Register the component path without .. so view:cache covers Flux Fix components compiling again after view:cache Oct 14, 2026
…vers it

Blade names a compiled view after the path the view finder returns, and view:cache compiles every file at its real path, so a path with ".." never finds the views view:cache compiled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv
@fgilio
fgilio force-pushed the register-views-at-their-real-path branch from 2df1ad2 to f1d2c52 Compare October 20, 2026 10:19
@fgilio
fgilio marked this pull request as ready for review October 20, 2026 10:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv
@fgilio
fgilio force-pushed the register-views-at-their-real-path branch from f1d2c52 to 3295088 Compare October 20, 2026 10:58
@fgilio

fgilio commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

FWIW laravel/framework#62005 has just been merged

@ganyicz

ganyicz commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks @fgilio !

@ganyicz
ganyicz merged commit 6aa10f6 into livewire:main Oct 26, 2026
1 check passed
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