4

I am using windows 7.

app\etc\config.php

<?php
return array (
  'modules' => 
  array (
    'Test_Module1' => 1,
  ),
);
?>

When I add My Test_Module1 in app\etc\config.php admin all pages(catalog,sales) throws error and and 127.0.0.1/magento20/module1/index/index url throws errors Error is:

a:4:{i:0;s:56:"Setup version for module 'Test_Module1' is not specified";i:1;s:2248:"#0 C:\xampp\htdocs\magento20\vendor\magento\framework\Module\DbVersionInfo.php(56): Magento\Framework\Module\DbVersionInfo->isModuleVersionEqual('Test_Module1', false)
#1 C:\xampp\htdocs\magento20\vendor\magento\framework\Module\DbVersionInfo.php(79): Magento\Framework\Module\DbVersionInfo->isSchemaUpToDate('Test_Module1')
#2 C:\xampp\htdocs\magento20\vendor\magento\framework\Module\Plugin\DbStatusValidator.php(55): Magento\Framework\Module\DbVersionInfo->getDbVersionErrors()
#3 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#4 C:\xampp\htdocs\magento20\vendor\magento\framework\Interception\Chain\Chain.php(68): call_user_func_array(Array, Array)
#5 C:\xampp\htdocs\magento20\vendor\magento\framework\Interception\Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'storeCookieVali...')
#6 C:\xampp\htdocs\magento20\vendor\magento\module-store\Model\Plugin\StoreCookie.php(78): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#7 [internal function]: Magento\Store\Model\Plugin\StoreCookie->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#8 C:\xampp\htdocs\magento20\vendor\magento\framework\Interception\Interceptor.php(141): call_user_func_array(Array, Array)
#9 C:\xampp\htdocs\magento20\var\generation\Magento\Framework\App\FrontController\Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#10 C:\xampp\htdocs\magento20\vendor\magento\framework\App\Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#11 C:\xampp\htdocs\magento20\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http->launch()
#12 C:\xampp\htdocs\magento20\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#13 {main}";s:3:"url";s:128:"/magento20/admin/admin/system_config/edit/section/advanced/key/501ed24319079b7b02cc894a5cb412b17b878bd2df98afefe85a9539080cb8c9/";s:11:"script_name";s:20:"/magento20/index.php";}

and If I remove My module from app\etc\config.php admin works fine but 127.0.0.1/magento20/module1/index/index does not work

magento20/app/code/composer.json

{
"name": "test/module1",
"description": "test module1 for Magento 2",
"require": {
    "php": "~5.5.0|~5.6.0"
},
"type": "magento2-module",
"version": "1.0.0",
"license": [
    "OSL-3.0",
    "AFL-3.0"
],
"autoload": {
    "files": [ "registration.php" ],
    "psr-4": {
        "test\\module1\\": ""
    }
}
}

magento20/app/code/registration.php

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

magento20/app/code/Test/Module1/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="Test_Module1" schema_version="1.0.0" setup_version="1.0.0"/> 
</config>

magento20/app/code/Test/Module1/etc/frontend/routes.xml

<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="module1" frontName="module1">
            <module name="Test_Module1" />
        </route>
    </router>
</config>

magento20/app/code/Test/Module1/Controller/Index/Index.php

<?php 
namespace Test\Module1\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action
{
    public function execute()
    {
        die('hi');
    }
}
?>
3
  • composer.json & registration.php need to be in app/code/Test/Module1. The attribute schema_version is not valid (in stable M2 version). Did you clean cache? Did you run setup:upgrade command line? Commented Dec 31, 2015 at 9:51
  • @test, is it working? Commented Dec 31, 2015 at 11:20
  • Check setup_module table if there is an entry of your module then delete it and run setup upgrade command again. Commented Oct 22, 2018 at 13:08

2 Answers 2

0

move your registration.php and composer.json files to your Test/Module1 root folder

and

change your module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="Test_Module1" schema_version="1.0.0" setup_version="1.0.0"/> 
</config>

to

<?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="Test_Module1" setup_version="1.0.0">
    </module>
</config>
4
  • Still not working please help me,I tried many tutorials but failed,I tried your code but still not work Commented Dec 31, 2015 at 12:03
  • I also clear cache Commented Dec 31, 2015 at 12:03
  • @test, which version you are using? Commented Dec 31, 2015 at 12:17
  • I downloaded yesterday from magento website Magento-CE-2.0.0-2015-11-17-05-47-46 Commented Dec 31, 2015 at 12:32
0

Add registration.php at location (magento20/app/code/Test/Module1/registration.php)

Code :

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

Open Command line in folder root of magento and run commands php bin/magento setup:upgrade

magento setup upgrade

More details

11
  • Still not working please help me,I tried many tutorials but failed, Commented Dec 31, 2015 at 12:03
  • I also clear cache Commented Dec 31, 2015 at 12:03
  • Open Command line in folder root of magento and run commands php bin/magento setup:upgrade Commented Dec 31, 2015 at 12:21
  • I tried php bin/magento setup:upgrade command.After apply this command automatically removed 'Test_Module1'=>1 from app\etc\config.php. Commented Dec 31, 2015 at 12:31
  • after upgrade command ,My Test_Module1 does not display means that my Test_module1 not loaded Commented Dec 31, 2015 at 12:36

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.