Follow bellow steps
Step: 1 (module.xml) app/code/Ccc/HelloWorld/etc/module.xml
<?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="Ccc_HelloWorld" setup_version="1.0.1">
</module>
</config>
Step: 2 app/code/Ccc/HelloWorld/composer.json
{
"name": "ccc/helloworld",
"description": "Ccc HelloWorld",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"amasty/base": "*"
},
"type": "magento2-module",
"version": "1.0.0",
"license": [
"Commercial"
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Ccc\\HelloWorld\\": ""
}
}
}
Step: 3 (routes.xml) app/code/Ccc/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="helloworld" frontName="helloworld">
<module name="Ccc_HelloWorld" />
</route>
</router>
</config>
Step: 4 (registration.php) app/code/Ccc/HelloWorld/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Ccc_HelloWorld',
__DIR__
);
Step: 5 (Index.php) app/code/Ccc/HelloWorld/Controller/Index/Index.php
<?php
namespace Ccc\HelloWorld\Controller\Index;
use Magento\Framework\View\Result\PageFactory;
class Index extends \Magento\Framework\App\Action\Action
{
protected $resultPageFactory;
/** * @param \Magento\Framework\App\Action\Context $context */
public function __construct(\Magento\Framework\App\Action\Context $context,PageFactory $resultPageFactory)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Hello World'));
return $resultPage;
}
}
Step: 6 (HelloWorld.php) app/code/Ccc/HelloWorld/Block/HelloWorld.php
<?php
namespace Ccc\HelloWorld\Block;
class HelloWorld extends \Magento\Framework\View\Element\Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
}
Step: 7 (helloworld_index_index.xml) app/code/Ccc/HelloWorld/view/frontend/layout/helloworld_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Ccc\HelloWorld\Block\HelloWorld" name="helloworld" template="helloworld.phtml">
</block>
</referenceContainer>
</body>
</page>
Step: 8 (helloworld.phtml) app/code/Ccc/HelloWorld/view/frontend/templates/helloworld.phtml
<?php
echo 'Successful! This is a simple module in Magento 2.0';
?>
Step: 9 Execute the commands
bin/magento module:enable Ccc_HelloWorld
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy