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;
 }
}
- 
 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.Yogesh Karodiya– Yogesh Karodiya2017年05月23日 08:45:29 +00:00Commented 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!perrivdb– perrivdb2017年05月23日 10:27:31 +00:00Commented May 23, 2017 at 10:27
- 
 If answer is helpful for you then accept answer that can can help for others.Yogesh Karodiya– Yogesh Karodiya2017年05月23日 10:44:10 +00:00Commented May 23, 2017 at 10:44
1 Answer 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.
- 
 Also comes if when lower case class written in namespace.Amit Singh– Amit Singh2017年05月23日 10:47:07 +00:00Commented May 23, 2017 at 10:47
Explore related questions
See similar questions with these tags.