Skip to content

[13.x] Resolve view namespace hints like view locations - #62005

Merged
taylorotwell merged 3 commits into
laravel:13.xfrom
fgilio:resolve-view-namespace-hints
Oct 20, 2026
Merged

taylorotwell merged 3 commits into
laravel:13.xfrom
fgilio:resolve-view-namespace-hints

Conversation

@fgilio

@fgilio fgilio commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

When a package registers its views through a path with .. in it, view:cache doesn't help. Each of its views compiles again on the first request that renders it.

Blade names a compiled view after the path the finder returns, and view:cache compiles each file at its real path. For a hint like __DIR__.'/../resources/views', those paths differ, and so do the compiled files.

I ran into this with Flux, which registers its components from src/../stubs/resources/views/flux. On a fresh app, after view:cache, rendering five Flux components still compiled 8 Flux views at runtime. On a read-only filesystem (#26357), those requests fail.

#26395 fixed this for view locations by running them through realpath() in FileViewFinder::resolvePath(). This PR does the same for namespace hints, in addNamespace(), prependNamespace() and replaceNamespace(). With it, the same app compiles no Flux view at runtime.

Backwards compatibility

  • resolvePath() keeps the path as given when realpath() fails, like it does for locations.
  • Only a hint that isn't already a real path changes, and its views were never precompiled anyway.
  • view:cache already compares paths by realpath() when it skips nested ones ([12.x] Deduplicate paths in view:cache #59145), so now the finder and the command agree.

Tests

  • ViewFileViewFinderTest: all three methods resolve hints, and a missing path stays as given.
  • BladeTest: view:cache compiles a view under a .. hint at the path it renders from. It fails without the change. It's skipped on Windows, where realpath() returns backslashes and the finder joins view names with /, so the two paths never match there, with or without this PR.
  • ExceptionReportingTest: the expected compiled path now comes from the resolved hint. It only differs on Windows.

livewire/flux#2856 makes the same fix inside Flux, for apps on Laravel 10, 11 and 12.

🤖 Generated with Claude Code

https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv

@github-actions

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

fgilio and others added 3 commits October 20, 2026 11:18
view:cache compiles every view at its real path, and Blade names a compiled
view after the path the finder returns. Locations are already resolved with
realpath(), but namespace hints are kept as given, so a package that registers
its views through a path with ".." gets none of them precompiled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv
realpath() returns a Windows path with backslashes, while the view finder joins
a view name with a forward slash, so view:cache never compiles a view at the
path it renders from on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KFfWQLT7PsmH3zswyjmqv
@fgilio
fgilio force-pushed the resolve-view-namespace-hints branch from cd758ca to 838a057 Compare October 20, 2026 10:19
@fgilio
fgilio marked this pull request as ready for review October 20, 2026 10:47
@fgilio

fgilio commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Please let me know if something should be different, I'm happy to iterate as needed

@taylorotwell
taylorotwell merged commit 0d6b451 into laravel:13.x Oct 20, 2026
62 checks 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