0

I'm building a Magento 2 module, I need to set up a frontpage page and show some information, I have created my routing:

routes.xml (in namespace/modulename/etc/frontend)

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
  <router id="standard">
    <route id="namespace_modulename" frontName="modulename">
        <module name="Namespace_ModuleName"/>
    </route>
 </router>
</config>

I have also my Controller:

<?php

namespace Namespace\ModuleName\Controller\Index;


use \Magento\Framework\App\Action\Context;

class Index extends \Magento\Framework\App\Action\Action
{

    /**
     * Index constructor.
     *
     * @param Context $context
     */
    public function __construct(
        Context $context
    ) {
        parent::__construct($context);
    }



    /**
     *
     * @return \Magento\Framework\View\Result\PageFactory
     */
    public function execute()
    {
        echo "Test";
        exit;
    }

}

When i go to modulename/index/index I'm getting g page not found.

Not sure why, any ideas? Already done magento upgrade and i can see the module there.

My module registration:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Namespace_ModuleName',
    __DIR__
);
0

app/code/Namespace/Modulename/etc/frontend/routes.xml

//Your content ok

app/code/Namespace/Modulename/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Namespace_Modulename" schema_version="1.0.1" setup_version="1.0.1"/>
</config>
0

Make sure your controller is located inside

namespace/modulename/Controller/Index

and create a module.xml file.

5
  • Already done, still cant get the hello world from the execute function on my browser, im getting page not found, already done re index also. – lucasvm1980 Oct 23 '18 at 15:33
  • Did you create module.xml file inside 'namespace/modulename/etc/' ? It should work. – Jim Oct 23 '18 at 16:28
  • Yes its working now, changed to lower case the letters. – lucasvm1980 Oct 23 '18 at 19:01
  • @lucasvm1980, have you fixed this issue ? – Shashank Kumrawat Oct 24 '18 at 16:07
  • Yes, using lowecase on module name. – lucasvm1980 Oct 24 '18 at 17:51

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.