Here is how my module structure looks



namespace Magento\Hello\Block;
class Hello extends \Magento\Framework\View\Element\Template
public function _prepareLayout()
    return parent::_prepareLayout();


namespace Magento\Hello\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action {
    protected $resultPageFactory;
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
        $this->resultPageFactory = $resultPageFactory;

    public function execute() {
        return $this->resultPageFactory->create();


<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="hello" frontName="hello">
        <module name="Magento_Hello" />


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
     <module name="Magento_Hello" schema_version="0.0.1" setup_version="0.0.1"/>


<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="content">
        <block class="Magento\Hello\Block\Hello" name="hello" template="Magento_Hello::success.phtml">


<?php echo ‘Successful! This is a simple module in Magento 2.0′; ?>



I have added the 'Magento_Hello' => 1 to the etc/config.php.

I am running Magento 2 on localhost.

  • I am wondering how you get answer. have you check your registration.php is correct? your registration.php should like @Rajkumar .E answer. – Bilal Usean Jun 2 '16 at 8:27
  • @BilalUsean I fixed it and now the module is working properly. – Sunil Neurgaonkar Jun 2 '16 at 9:03

You have to run command

php bin/magento setup:upgrade

using cmd.

This command enable module in your system and one entry are generated under setup_module table.

Directly you can't generate entry inside app/etc/config.php file.

Remove var folder and try again.

  • tun php bin/magento setup:upgrade then i run php bin/magento setup:di:compile and now i have errors after running that command – Sunil Neurgaonkar Jun 1 '16 at 9:00
  • which error are generate plz show that – Rakesh Jesadiya Jun 1 '16 at 9:05
  • Which version you've got of Magento 2? In the last update they fix the setup:di:compile , if you have previous version, try to use setup:di:compile:multi-tenant – ntzz says Reinstate Monica Jun 1 '16 at 9:09
  • I had the php memory error but i fixed it. so the command is run successfully. everything is successfully done but still i cant see the module. – Sunil Neurgaonkar Jun 1 '16 at 9:18
  • have you remove var folder from root – Rakesh Jesadiya Jun 1 '16 at 9:19

The simple solution is to create module online using "Magento 2 Module Creator | CedCommerce" . you need to complete 2-3 basic and simple steps then you can download and install your plugin to your website by following steps :

  1. Unzip the downloaded module and paste into the "your_project/app/code/your downloded module
  2. sudo php bin/magento setup:upgrade
  3. rm -rf var/di/* var/generation/* var/cache/* var/page_cache/* var/view_preprocessed/* var/composer_home/cache/*
  4. sudo php bin/magento setup:di:compile
  5. sudo php bin /magento cache:clean
  6. sudo chmod 777 var -R
  7. sudo chmod 777 pub -R

After completing these steps you will find your Magento module working.


I thinks you need to change registration.php like this


Then Delete var folder and run setup:upgrade command. Then check it.


Is that a valid way to define a template? In your hello_index_index.xml? I thought that was for block methods?

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.