Fixed: Livewire "Method Not Found" Error After Renaming Component

The problem: After renaming a Livewire component class or moving its file, calling an action on it throws a method-not-found error, even though the method clearly exists in the current file.

Environment: Laravel 11, Livewire 3.x, PHP 8.3

The Error

● ● ●  console / server log
Livewire\Exceptions\MethodNotFoundException: Unable to call component
method. Public method [save] not found on component:
[app.livewire.old-name-component]

Why It Happens

Livewire identifies components by a generated alias string (usually derived from the class's namespace and name), and that alias gets baked into the rendered HTML as a wire:id/snapshot reference when the page is first loaded. Renaming a component class or moving its file changes what alias Livewire would generate going forward — but if the browser is holding an already-rendered page from before the rename, its cached component payload still references the old alias.

This shows up in a few overlapping ways:

1. Browser-cached page — the user's currently open tab loaded the component under its old name and never refreshed, so every subsequent Livewire request references a class Laravel can no longer resolve to the new file.

2. Laravel's compiled view cache — if @livewire('old-name') is hardcoded somewhere and Blade's compiled cache wasn't cleared, the old tag keeps rendering even after you've updated the source Blade file to reference the new name.

3. OPcache on production — a renamed class file can leave a stale OPcache entry pointing at class metadata from before the file move, especially on servers where OPcache's validate_timestamps is disabled for performance.

The Fix

First, confirm every reference to the component uses the new name consistently — the class file, the Blade view path, and any @livewire() or <livewire:...> tags:

resources/views/dashboard.blade.php
- @livewire('old-name-component')
+ <livewire:new-name-component />

Clear every layer of Laravel's cache that could be holding onto the old reference:

php artisan view:clear
php artisan cache:clear
php artisan route:clear
php artisan config:clear

On production servers with OPcache, restart PHP-FPM so stale class metadata from the old file path is dropped:

sudo service php8.3-fpm restart

Finally, tell the affected user to do a hard refresh (or simply reload the tab) — no server-side fix can force an already-open browser tab to drop its stale Livewire component snapshot.

Step-by-Step

  1. Search the entire codebase for the old component name: grep -r "old-name-component" resources/ app/.
  2. Update any remaining @livewire() calls or <livewire:old-name /> tags to the new name.
  3. Run php artisan view:clear, cache:clear, route:clear, and config:clear in sequence.
  4. On production, restart PHP-FPM to flush any stale OPcache class metadata.
  5. Hard-refresh the browser tab that was open during the rename (Ctrl+Shift+R) before testing the action again.
  6. Confirm the method now executes by checking the Network tab for a 200 response on the next wire:click.

Edge case: If you renamed the component's namespace (moved it into a subfolder) rather than just the class name, Livewire's auto-discovery relies on the folder structure under app/Livewire matching the dot-notation name used in Blade — a mismatch here throws a similar-looking but subtly different "component not found" error rather than "method not found," so double-check the exact exception message before assuming it's purely a caching issue.

Still hitting method-not-found after clearing all caches? Reach out on the Contact page and I'll help trace it.

Advertisement
Advertisement