Fatal Error: Class contains 1 abstract method and must therefore be declared abstract or implement the remaining methods

Hello everyone,
I am new to Laminas and while following the tutorial, I encountered an error when creating my first controller.

PHP Fatal error: Class Site\Controller\IndexController contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Laminas\Mvc\Controller\AbstractController::onDispatch)

What does this mean?
What’s the function of this onDispatch method?
Why is it necessary I add it to my Controller?

On the tutorial building album application, there is nothing like that.

Thank you.

@josiahking which tutorial? I do not recall a tutorial where Site\Controller\IndexController is used.

That’s my own created controller while following the album tutorial.

@josiahking Album tutorial suggests Laminas\Mvc\Controller\AbstractActionController

You extended Laminas\Mvc\Controller\AbstractController, which is not aware about actions.
What you want is Laminas\Mvc\Controller\AbstractActionController; AbstractActionController extends AbstractController and implements AbstractController::onDispatch() to select and execute appropriate action method.

1 Like

I didn’t see that. Fixed it, everything is working well.
Thank you.