magento 2에서 사용자 정의 모듈을 만드는 중이지만 작동하지 않습니다. 내가 어디로 잘못 갔는지 제안 해 주시겠습니까?.
내 모듈 코드 :
app / etc / config.php :
'modules' =>
array (
'Ramesh_Sample' => 1,
),
앱 / 코드 /Ramesh/Sample/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Ramesh_Sample" schema_version="2.0.0">
</module>
</config>
app / code / Ramesh / Sample / etc / frontend / routes.xml
<?xml version="1.0"?>
<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="sample" frontName="sample">
<module name="Ramesh_Sample" />
</route>
</router>
</config>
app / code / Ramesh / Sample / Controller / Index / Index.php
<?php
namespace Ramesh\Sample\Controller\Index;
use Magento\Framework\App\Action\Context;
//use \Magento\Framework\View\Result\PageFactory;
class Index extends \Magento\Framework\App\Action\Action
{
private $_resultPageFactory;
public function __construct(
Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
)
{
parent::__construct($context);
$this->_resultPageFactory = $resultPageFactory;
}
public function execute()
{
$result = $this->_resultPageFactory->create();
return $result;
}
}
앱 / 코드 /Ramesh/Sample/Block/Sample.php
namespace Magento\Sample\Block;
class Sample extends \Magento\Framework\View\Element\Template
{
}
app / code / Ramesh / Sample / views / frontend / layout / sample_index_index.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<title>Hello World</title>
</head>
<body>
<referenceContainer name="content">
<block class="Sample\Ramesh\Block\Sample" name="sample" template="sample.phtml">
</block>
</referenceContainer>
</body>
</page>
app / code / Ramesh / Sample / view / frontend / templates / sample.phtml
<?php echo 'Hi I am Magento 2'; ?>
그러나 다음과 같은 오류가 발생했습니다.
a : 4 : {i : 0; s : 380 : "복구 가능한 오류 : 인수 2가 Ramesh \ Sample \ Controller \ Index \ Index :: __ construct ()에 전달 된 인수 2는 Magento \ Framework \ View \ Result \ PageFactory의 인스턴스 여야합니다. 14 번째 줄의 var / generation / Ramesh / Sample / Controller / Index / Index / Interceptor.php에서 호출되고 14 번째 줄의 app / code / Ramesh / Sample / Controller / Index / Index.php에 정의되지 않았습니다 "; i : 1; s : 6109 : "# 0 app / code / Ramesh / Sample / Controller / Index / Index.php (14) : Magento \ Framework \ App \ ErrorHandler-> handler (4096, '인수 2 패스 ...', '/ var / www / html / m ...', 14, 배열)