@synchro of course authorizeResource will not works for invokable controller, because it doesn't have resource actions.
Now about policy: Did you register it correctly? Which methods you have in policy? Can you show your policy?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a set of invokable single action controllers for an API resource. I also have a policy for the underlying model. The controllers have a base class that tells it to authorize requests in its constructor:
$this->authorizeResource(Product::class, 'product');
The problem seems to be that these policy methods are never triggered. Do invokable controllers and policies not get on? Does the lack of an action name (because it's always __invoke) mean that the action to policy name mapping (e.g. index -> viewAny) doesn't work?
To be clear, I'm also calling:
$this->authorize('viewAny', Product::class);
from within the __invoke method of the index controller, but I'm wondering if that fails to make the connection to the policy for the product model, since that method is never called.
Yes, that's what I was trying. It was very odd - I could get it to trigger some policy calls but not others.
I've now solved it by moving all the invokables into a single resource controller, and now the policy works fine.
Please or to participate in this conversation.