1

I develop one custom module but its redirecting to 404 page and also it not create my custom table (once i run upgrade cli it will make entry in config.php and set) but its work fine on beta version below are the i used please correct me where i did mistakes
app\code\Sugarcode\Test\registration.php

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Sugarcode_Test',
    __DIR__
);

app\code\Sugarcode\Test\composer.json

{
    "name": "sugarcode/module-test",
    "description": "N/A",
    "require": {
        "php": "~5.5.0|~5.6.0|~7.0.0",
        "magento/module-config": "100.0.*",
        "magento/module-store": "100.0.*",
        "magento/module-backend": "100.0.*",
        "magento/module-customer": "100.0.*",
        "magento/module-cms": "100.0.*",
        "magento/framework": "100.0.*"
    },
    "type": "magento2-module",
    "version": "100.0.1",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "autoload": {
        "files": [
            "registration.php"
        ],
        "psr-4": {
            "Sugarcode\\Test\\": ""
        }
    }
}

app\code\Sugarcode\Test\etc\module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Sugarcode_Test" setup_version="2.0.6" />
</config>

app\code\Sugarcode\Test\etc\frontend\routes.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
    <router id="standard">
        <route id="test" frontName="test">
            <module name="Sugarcode_Test" />
        </route>
    </router>
</config>

app\code\Sugarcode\Test\Controller\Index\Index.php

class Index extends \Magento\Framework\App\Action\Action
{
        /**
         * @var \Magento\Framework\View\Result\PageFactory
         */
        protected $resultPageFactory;

    /**
     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\View\Result\PageFactory resultPageFactory
     */
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    )
    {
        $this->resultPageFactory = $resultPageFactory;
        parent::__construct($context);
    }
/**
 * Default customer account page
 *
 * @return void
 */
public function execute()
{
    echo 'Hello'; exit;
    return $this->resultPageFactory->create();
}

}

i exit in action but its not exiting it show 404 error page

url is domin.com/test

can any one help me on this

6
  • have you remove cache and generation folder from var? Commented Nov 17, 2015 at 9:58
  • This is a known problem in Magento2 RC2, see: github.com/magento/magento2/issues/2381 for details (wrong composer.json generated at build of RC2) Commented Nov 17, 2015 at 10:01
  • @RBJesadiya i did it but no luck Commented Nov 17, 2015 at 10:03
  • @VladimirKerkhoff:- thanks so i need to wait till next release Commented Nov 17, 2015 at 10:04
  • have you checked your module is enable in admin? Have you run command setup:upgrade using cli. Commented Nov 17, 2015 at 10:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.