I’m creating the test module form the Magento 2 Development Fundamentals course from Magento and ran accross the below error:

Recoverable Error: Argument 1 passed to Training\Test\Controller\Action\Config::__construct() must be an instance of Magento\Framework\App\Action\Context

I found out that the example they gave, they omitted the constructor in the Config.php controller. So let’s add that in:

public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;

Then lastly, since I already tried to run it, I had to clear out some of my var folders and then recompile:

[bessig@dev htdocs]$ sudo rm -Rf var/generation/*
[bessig@dev htdocs]$ sudo rm -Rf var/di
[bessig@dev htdocs]$ sudo rm -Rf var/cache/*
[bessig@dev htdocs]$ sudo rm -Rf var/page_cache/*
[bessig@dev htdocs]$ bin/magento setup:di:compile

Hopefully this helps someone.

Also they did not supply a routes.xml The one I used is as follows:

The page you will call using this route will be: /testing/action/config

Hopefully this saves someone some time! Let me know if your one of the people it helped!

Leave a Comment

Your email address will not be published. Required fields are marked *