I am facing a 404 page not found error while trying to setup a simple module in Magento 2.4.3-p1.
I have seen different threads related to the issue I am having, none worked for me nor gave me any clue on the issue source.
I have my module in `app/code/{vendorname}/{modulename}`.
I have followed the typical structure anyone find in any tutorial online, added `registration.php`, `etc/module.xml`, `etc/frontend/routes.xml`, `Controller/{controllername}/{actionclass}.php`.
I have tried:
magento module:enable {modulename}
magento setup:update
magento s:s:d -f
magento cache:clean
magento c:f(the usual commands..) Also, I have deleted var and generated folders before running the commands again, nd still having 404 not found.
I have some customization in `view/frontend/layout/default.xml` which works great in the same module.
My Files are as follows:
Controller:
<?php
namespace {Vendorname}\FirstModule\Controller\Test;
use Magento\Framework\App\Action\Action;
class Index extends Action
{
public function __construct(\Magento\Framework\App\Action\Context $context)
{
return parent::__construct($context);
}
public function execute()
{
echo "<h1> HOHO </h1>";
exit;
}
}<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="firstmodule" frontName="firstmodule">
<module name="{Vendorname}_FirstModule" />
</route>
</router>
</config>Solved! Go to Solution.
I found out that the module name was the issue since it has to be the same and case-sensitive.