Route not found for Filament Resource Page
I'm an experienced PHP/Symfony developer, my experience with Laravel and Filament is very limited. I apologise in advance for a trivial question.
I created a new Resource, with two pages:
index
, and issue
. Autodiscovery seems to work fine, when I run the route:list
command from the command line, I see the routes:
When I try to use the route in Filament's Action, I get the following error:
Well, clearly it's defined, as route:list
lists that route... so not sure what is going on here.
I have tried clearing cache, restarting the app, even restarted my PC.
The relevant PHP code that tries to use the route is:
PremiumResource
class:
ListPremiums
extends ListRecords
, while IssuePremium
extends EditRecord
.
Thank you.Solution:Jump to solution
I deleted
bootstrap/cache/filament
folder and now it automagically works...19 Replies
The relevant PHP code that tries to use the route is:Where do you use that code? In a ServiceProvider? It might run before routes are registered.
in the
RelationManager
on listed records. I have identical set up to list customers and it works fine...
the working RelationManager
looks like this:
Should be okay. I wouldn't use the
route()
method directly though. You can use PremiumsResource::getUrl('issue', ['record' => $p->id])
instead which should be more reliable.
Does this maybe solve the error?it did not, it's really a wrapper on
route()
method, throws the same error.
it's really a wrapper on route() methodYeah, makes sense 🙈 Hm, it's weird. I think I have seen the issue from times to times but it always "magically appears and disappears" again. Can it be some OpCaching? As it works on the CLI but not the browser? Can you try dumping
Route::getRoutes()
on any route?Routes are not listed, when I dump the
Route::getRoutes()
output.
I mean the premium
related 2 routes are missing.Sounds like OpCache to me then. What's you OS and dev environment?
I guess that should be fixed by a restart though. 🤔
Solution
I deleted
bootstrap/cache/filament
folder and now it automagically works...Sounds like OpCache to me then. What's you OS and dev environment?Fedora Linux (latest) with PHP 8.3.20
Well, if deleting that folder helped it's probably not OpCache. Did you run
artisan filament:optimize
or similar at any point?weird that running
php artisan cache:clear
didn't clear it
Did you run artisan filament:optimize or similar at any point?No, just
php artisan cache:clear
😞
but I may have run it earlier (before 3 weeks holiday I just returned from 😅 )optimize
is the reverse and I think cache:clear
doesn't work for the "Filament cache". That's why I'm askingI'll just make myself another
make
target to clear cache + optimiseThere is
artisan filament:optimize-clear
to clear the Filament optimisations.I guess I do not need them on local dev, right?
The Blade icon cache could help. See whether you notice a difference 😅
😅
Thank you for your help!
@Dennis Koch would it make sense to hook
optimize-clear
when user requests cache:clear
? 🤔Doesn't optimize-clear run cache:clear?
possibly