Skip to main content

I also just tried yesterday and succeeded to make my own hello world magento 2 module. I followed this tutorial to create a simple Magento 2 module, there are 6 steps as below

Step 1: Make module folder:=> Step 1: Make module folder:

app/code/Magentoexplorer/Helloworld

app/code/Magentoexplorer/Helloworld

Step 2: Add module.xml to declear the module=> Step 2: Add module.xml to declear the module

    <?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="Magentoexplorer_Helloworld" setup_version="1.0.0" />
</config>

Step 3: Create registration.php to register the module=> Step 3: Create registration.php to register the module

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

Step 4: How to Install, Enable or Disable/remove the module=> Step 4: How to Install, Enable or Disable/remove the module

cd [magento_directory]
php bin/magento setup:upgrade

Step 5: Route of the module. create app/code/Magentoexplorer/Helloworld/etc/frontend/routes.xml=> Step 5: Route of the module. create app/code/Magentoexplorer/Helloworld/etc/frontend/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="magentoexplorer" frontName="helloworld">
            <module name="Magentoexplorer_Helloworld" />
        </route>
    </router>
</config>

Step 6: Controller and action.=> Step 6: Controller and action.

app/code/Magentoexplorer/Helloworld/Index/Index.php

app/code/Magentoexplorer/Helloworld/Index/Index.php

<?php
namespace Magentoexplorer\Helloworld\Controller\Index;
 
class Display extends \Magento\Framework\App\Action\Action
{
  public function __construct(
\Magento\Framework\App\Action\Context $context)
  {
    return parent::__construct($context);
  }
 
  public function execute()
  {
    echo 'Hello World';
    exit;
  }
}

I also just tried yesterday and succeeded to make my own hello world magento 2 module. I followed this tutorial to create a simple Magento 2 module, there are 6 steps as below

Step 1: Make module folder:

app/code/Magentoexplorer/Helloworld

Step 2: Add module.xml to declear the module

    <?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="Magentoexplorer_Helloworld" setup_version="1.0.0" />
</config>

Step 3: Create registration.php to register the module

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

Step 4: How to Install, Enable or Disable/remove the module

cd [magento_directory]
php bin/magento setup:upgrade

Step 5: Route of the module. create app/code/Magentoexplorer/Helloworld/etc/frontend/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="magentoexplorer" frontName="helloworld">
            <module name="Magentoexplorer_Helloworld" />
        </route>
    </router>
</config>

Step 6: Controller and action.

app/code/Magentoexplorer/Helloworld/Index/Index.php

<?php
namespace Magentoexplorer\Helloworld\Controller\Index;
 
class Display extends \Magento\Framework\App\Action\Action
{
  public function __construct(
\Magento\Framework\App\Action\Context $context)
  {
    return parent::__construct($context);
  }
 
  public function execute()
  {
    echo 'Hello World';
    exit;
  }
}

I also just tried yesterday and succeeded to make my own hello world magento 2 module. I followed this tutorial to create a simple Magento 2 module, there are 6 steps as below

=> Step 1: Make module folder:

app/code/Magentoexplorer/Helloworld

=> Step 2: Add module.xml to declear the module

    <?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="Magentoexplorer_Helloworld" setup_version="1.0.0" />
</config>

=> Step 3: Create registration.php to register the module

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

=> Step 4: How to Install, Enable or Disable/remove the module

cd [magento_directory]
php bin/magento setup:upgrade

=> Step 5: Route of the module. create app/code/Magentoexplorer/Helloworld/etc/frontend/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="magentoexplorer" frontName="helloworld">
            <module name="Magentoexplorer_Helloworld" />
        </route>
    </router>
</config>

=> Step 6: Controller and action.

app/code/Magentoexplorer/Helloworld/Index/Index.php

<?php
namespace Magentoexplorer\Helloworld\Controller\Index;
 
class Display extends \Magento\Framework\App\Action\Action
{
  public function __construct(
\Magento\Framework\App\Action\Context $context)
  {
    return parent::__construct($context);
  }
 
  public function execute()
  {
    echo 'Hello World';
    exit;
  }
}
Source Link
Hung Tran
  • 451
  • 4
  • 7

I also just tried yesterday and succeeded to make my own hello world magento 2 module. I followed this tutorial to create a simple Magento 2 module, there are 6 steps as below

Step 1: Make module folder:

app/code/Magentoexplorer/Helloworld

Step 2: Add module.xml to declear the module

    <?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="Magentoexplorer_Helloworld" setup_version="1.0.0" />
</config>

Step 3: Create registration.php to register the module

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

Step 4: How to Install, Enable or Disable/remove the module

cd [magento_directory]
php bin/magento setup:upgrade

Step 5: Route of the module. create app/code/Magentoexplorer/Helloworld/etc/frontend/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="magentoexplorer" frontName="helloworld">
            <module name="Magentoexplorer_Helloworld" />
        </route>
    </router>
</config>

Step 6: Controller and action.

app/code/Magentoexplorer/Helloworld/Index/Index.php

<?php
namespace Magentoexplorer\Helloworld\Controller\Index;
 
class Display extends \Magento\Framework\App\Action\Action
{
  public function __construct(
\Magento\Framework\App\Action\Context $context)
  {
    return parent::__construct($context);
  }
 
  public function execute()
  {
    echo 'Hello World';
    exit;
  }
}