Video Lesson: Create a controller action in Magento

Create a controller action in Magento

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

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...

Premium content

Enroll to unlock the full content and all course materials.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.