Hello,
I have create new custom module and run frontend get 404 Page error.
How to debug module what problem in code ?
Please Help me.
THANKS.
Hello,
I have create new custom module and run frontend get 404 Page error.
How to debug module what problem in code ?
Please Help me.
THANKS.
Check This Steps
Step-1 : First you need to check your module is enable or not.
Step-2 : You need to check are you working on right magento url or not.
Step-3 : Check your Route name in routes.xml app\code\VendoreName\ModuleName\etc\frontend
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route frontName="yourroutename" id="yourroutename">
<module name="VendoreName_ModuleName"/>
</route>
</router>
</config>
Step-4 : In above File must be there
Step-5 : Then create contoller (Index) app\code\VendoreName\ModuleName\Controller\Index
Step-6 : Add Action file like this (Index.php) at app\code\VendoreName\ModuleName\Controller\Index (Class Name and File Name must be same)
<?php
namespace VendoreName\ModuleName\Controller\Index;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Result\PageFactory;
class Index extends \Magento\Framework\App\Action\Action
{
protected $resultPageFactory;
protected $customerSession;
public function __construct(
Context $context,
PageFactory $resultPageFactory,
Session $customerSession
) {
$this->resultPageFactory = $resultPageFactory;
$this->customerSession = $customerSession;
parent::__construct($context);
}
public function execute()
{
return $this->resultPageFactory->create();
}
}
Step-7 : Create layout for it in app\code\VendoreName\ModuleName\view\frontend\layout
Step-8 : Layout File name must be like this FrontendRouteName_FrontendControllerName_ActionFileName.xml
Step-9 : Add Blank Page layout like this
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
</referenceContainer>
</page>
Step-10 : Must be Run Magento Upgrade command before check in fronend.
Note: You can check and Compare your code with above code.
I Hope This helps You