Create a controller action in Magento
Learn how to create a Magento controller action for the blog route using HttpGetActionInterface and execute.
Lesson Content
Even though we have our module set up to handle web requests for the blog URL, if we try to load the /blog URL, a 404 error page will be returned. This is because even though our route is set up, a controller must also exist to be able to handle the incoming request.
A controller is just a regular PHP class. Magento looks for controllers in the Controller folder of a module, so let’s go ahead and create it. Be very sure to capitalize the C in Controller, otherwise you’ll have all sorts of odd errors eventually on case sensitive operating systems.
It’s a good time to remember that M...
Join the discussion!
Comments
Want to comment on this lesson?
Enroll in this course to leave comments.