5

I have a created a frontend controller on location Namespace/Mymodule/Controller/Schedule.php

namespace Namespace\Mymodule\Controller;
class Schedule extends \Magento\Framework\App\Action\Action
{
  public function execute()
  {
    die("Hello");
  }
}

routes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
  <router id="standard">
     <route id="mymodule" frontName="mymodule">
        <module name="Namespace_Mymodule" />
    </route>
  </router>
</config>

Now when I try to manually call this action by http://localhost/magento2/mymodule/schedule (as i am working on localhost) that time I am getting an 404-Not found page.

Where I am going to wrong ?

Thank you in advance.

3

Your controller structure is wrong it shold be look like Namespace/Mymodule/Controller/Index/Schedule.php

URL is: http://localhost/magento2/mymodule/index/schedule

change namespace to Namespace\Mymodule\Controller\index

0

Create controller Namespace\Mymodule\Controller\Schedule\Index.php

add below code:

namespace Namespace\Mymodule\Controller\Schedule;
class Index extends \Magento\Framework\App\Action\Action
{
  public function execute()
  {
    die("Hello");
  }
}
0

You can check if you put routes.xml in the wrong place. I also have the same problem , And I finally figured out that I should create the file in this path

app/etc/frontend/routes.xml

instead of app/etc/routes.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.