이 게시물에 표시된 모듈을 만들었 습니다. 그러나 내 컨트롤러가 작동하지 않습니다. 이 오류 메시지가 나타납니다.
복구 가능한 오류 : MP \ MyModule \ Controller \ Index \ CheckUserName :: __ construct ()에 전달 된 인수 1은 Magento \ Framework \ App \ Action \ Context의 인스턴스 여야하고 D에서 호출 된 Magento \ Framework \ ObjectManager \ ObjectManager의 인스턴스 여야합니다. : \ xampp \ htdocs \ magento2 \ vendor \ magento \ framework \ ObjectManager \ Factory \ AbstractFactory.php 97 행에 D : \ xampp \ htdocs \ magento2 \ app \ code \ mp \ MyModule \ Controller \ Index \ CheckUserName에 정의되어 있습니다. 35 행의 PHP
내 컨트롤러 코드는 다음과 같습니다.
<?php
namespace MP\MyModule\Controller\Index;
class CheckUserName extends \Magento\Framework\App\Action\Action
{
protected $_logger;
protected $_objectManager;
protected $_request;
/*
\Psr\Log\LoggerInterface $logger, //log injection
\Magento\Framework\App\Request\Http $request
$this->_logger = $logger;
$this->_logger->debug('CheckUserName_Constructor_Begin');
$this->_request = $request;
$this->_logger->debug('CheckUserName_Constructor_End');
*/
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory resultPageFactory
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
)
{
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
public function execute()
{
echo "Hello from Checkusername";
}
}
?>
var / generation 폴더를 삭제 한 후 발생하는 오류 메시지는 다음과 같습니다.
Warning: ltrim() expects parameter 1 to be string, object given in D:\xampp\htdocs\magento2\vendor\magento\framework\Code\Generator\EntityAbstract.php on line 152
Notice: Uninitialized string offset: 0 in D:\xampp\htdocs\magento2\vendor\magento\framework\Autoload\ClassLoaderWrapper.php on line 81
Notice: Uninitialized string offset: 0 in D:\xampp\htdocs\magento2\vendor\composer\ClassLoader.php on line 317
Notice: Uninitialized string offset: 0 in D:\xampp\htdocs\magento2\vendor\composer\ClassLoader.php on line 349 exception 'Magento\Framework\Exception\LocalizedException' with message 'Source class "" for "Magento\Framework\App\Response\Http\Interceptor" generation does not exist.' in D:\xampp\htdocs\magento2\vendor\magento\framework\Code\Generator.php:171 Stack trace: #0 D:\xampp\htdocs\magento2\vendor\magento\framework\Code\Generator.php(100): Magento\Framework\Code\Generator->tryToLoadSourceClass('Magento\\Framewo...', Object(Magento\Framework\Interception\Code\Generator\Interceptor))
#1 D:\xampp\htdocs\magento2\vendor\magento\framework\Code\Generator\Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\\Framewo...')
#2 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Framewo...')
#3 D:\xampp\htdocs\magento2\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(105): spl_autoload_call('Magento\\Framewo...')
#4 D:\xampp\htdocs\magento2\vendor\magento\framework\ObjectManager\Factory\Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#5 D:\xampp\htdocs\magento2\vendor\magento\framework\ObjectManager\Factory\Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...')
#6 D:\xampp\htdocs\magento2\vendor\magento\framework\ObjectManager\Factory\Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Framewo...')
#7 D:\xampp\htdocs\magento2\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Framewo...', Array)
#8 D:\xampp\htdocs\magento2\vendor\magento\framework\App\Bootstrap.php(233): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Framewo...', Array)
#9 D:\xampp\htdocs\magento2\index.php(38): Magento\Framework\App\Bootstrap->createApplication('Magento\\Framewo...')
#10 {main}