Hello Magento Friends,

In today’s Magento 2 Tutorial Blog, I am going to justify How to Get Controller of Each Request in Magento 2.

Controller in Magento 2 is a file located at a specific place and it responds to a specific URL. If you want to get and print the name of each controller that is called at a specific request, then you need to follow the below steps.

Steps to Get Controller of Each Request in Magento 2:

Step 1: Create a file at the below path

app\code\Vendor\Extension\etc\events.xml

Now, add the following code

Step 2: Create a file at the following path

app\code\Vendor\Extension\Observer\MyClass\ControllerActionPredispatch.php

Then, add the below-mentioned code

Conclusion:

Accordingly, you can easily Get Controller of Each Request in Magento 2. Get User Data Inside Controller in Magento 2. In case of any difficulty, let me know via the comment section. Share the article with others and stay in the know.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]