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');
}
}
?>
Best Answer
move your
registration.php
andcomposer.json
files to your Test/Module1 root folderand
change your
module.xml
to