I'm using Magento 2 CE Version 2.1.0
I'm following http://www.mage-world.com/blog/how-to-create-a-simple-module-in-magento-2-0.html
I have followed steps when i run it gives below error.
{folder path}\magento2\app\code\Custom\Module\Controller\Index\Index.php
namespace Custom\Module\Controller\Index;
use Magento\Framework\Controller\Result\ForwardFactory;
use Magento\Framework\App\Action\Context;
class Index extends \Magento\Framework\App\Action\Action {
/**
* @var \Magento\Framework\Controller\Result\ForwardFactory
*/
protected $resultForwardFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
*/
public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
) {
$this->resultForwardFactory = $resultForwardFactory;
parent::__construct($context);
}
public function execute() {
$resultPageFactory = $this->resultPageFactory->create();
// Add page title
$resultPageFactory->getConfig()->getTitle()->set(__('Sample Module'));
// Add breadcrumb
/** @var \Magento\Theme\Block\Html\Breadcrumbs */
$breadcrumbs = $resultPageFactory->getLayout()->getBlock('breadcrumbs');
$breadcrumbs->addCrumb('home', [
'label' => __('Home'),
'title' => __('Home'),
'link' => $this->_url->getUrl('')
]
);
$breadcrumbs->addCrumb('custom_module', [
'label' => __('Test'),
'title' => __('Test')
]
);
return $resultPageFactory;
}
}
1 exception(s): Exception #0 (Exception): Recoverable Error: Argument 2 passed to Custom\Module\Controller\Index\Index::__construct() must be an instance of Magento\Framework\Controller\Result\ForwardFactory, none given, called in {folder path}\magento2\var\generation\Custom\Module\Controller\Index\Index\Interceptor.php on line 14 and defined in {folder path}\magento2\app\code\Custom\Module\Controller\Index\Index.php on line 21