1

Created a module which was working for a long time, however after some other edits to the site I got this error:

"Recoverable Error: Argument 1 passed to vendor\module\Controller\Cart\Index::__construct() must be an instance of Magento\Framework\App\Action\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /Applications/MAMP/htdocs/project/shop/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /Applications/MAMP/htdocs/project/shop/app/code/vendor/module/Controller/Cart/index.php on line 14"

Removing var/generation, var/di and var/cache folders solve the problem, however, it reappears after setup:di:compile

Any thoughts on possible fixes?

Here is the controller code:

<?php
namespace vendor\module\Controller\Cart;
class Index extends \Magento\Framework\App\Action\Action {
 /** @var \Magento\Framework\View\Result\Page */
 protected $resultPageFactory;
 /** * @param \Magento\Framework\App\Action\Context $context */
 public function __construct(\Magento\Framework\App\Action\Context $context,
 \Magento\Framework\View\Result\PageFactory $resultPageFactory) {
 $this->resultPageFactory = $resultPageFactory;
 parent::__construct($context);
 }
 /**
 * Blog Index, shows a list of recent blog posts.
 *
 * @return \Magento\Framework\View\Result\PageFactory
 */
 public function execute()
 {
 header('Content-Type:text/plain');
 header("Access-Control-Allow-Origin: *");
 $resultPage = $this->resultPageFactory->create();
 return $resultPage;
 }
}
Yogesh Karodiya
3,1214 gold badges21 silver badges42 bronze badges
asked May 23, 2017 at 7:57
3
  • This error may occur due to use of case sensitive name in controller or your module. This type of error only generate after compilation. If possible write your code how your controller is calling, it will help for find exact possible reason. Commented May 23, 2017 at 8:45
  • Legend! checked all class names etc beforehand, but didn't check the filename, it was called index instead of Index. problem solved! Commented May 23, 2017 at 10:27
  • If answer is helpful for you then accept answer that can can help for others. Commented May 23, 2017 at 10:44

1 Answer 1

1

This error may occur due to use of case sensitive name in controller or module. Generally this error ignore without the code compilation. This type of error only generate after compilation. It seems that in your code:

shop/app/code/vendor/module/Controller/Cart/index.php

You used i instead of I.

Amit Singh
1,7854 gold badges20 silver badges38 bronze badges
answered May 23, 2017 at 10:42
1
  • Also comes if when lower case class written in namespace. Commented May 23, 2017 at 10:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.