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; } }