cancel
Showing results for 
Search instead for 
Did you mean: 

DevDocs example for Creating a Magento admin page throws error

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

DevDocs example for Creating a Magento admin page throws error

  namespace WDT\Faq\Controller\Adminhtml\Menu;
  class Index extends \Magento\Backend\App\Action
  {
    /**
    * @var \Magento\Framework\View\Result\PageFactory
    */
    protected $resultPageFactory;
    /**
     * Constructor
     *
     * @param \Magento\Backend\App\Action\Context $context
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
     */
    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    ) {
         parent::__construct($context);
         $this->resultPageFactory = $resultPageFactory;
    }
    /**
     * Load the page defined in view/adminhtml/layout/faq_menu_index.xml
     *
     * @return \Magento\Framework\View\Result\Page
     */
    public function execute()
    {
         return  $resultPage = $this->resultPageFactory->create();
    }
  }

That's my index.php for a module I'm trying to add to the admin pages. When I click the link to open that page, it throws me an error :

PHP Fatal error:
    Uncaught TypeError: Argument 1 passed to WDT\\Faq\\Controller\\Adminhtml\\Menu\\Index::__construct()
    must be an instance of Magento\\Backend\\App\\Action\\Context,
    instance of Magento\\Framework\\ObjectManager\\ObjectManager given,
    called in /var/www/html/shop/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93
    and defined in /var/www/html/shop/app/code/WDT/Faq/Controller/Adminhtml/Menu/index.php:17

AFAIK I followed the steps as layed out in http://devdocs.magento.com/guides/v2.1/ext-best-practices/extension-coding/example-module-adminpage.... but it keeps giving me that error. And I don't know what I am doing wrong. Cleaned the cache, Ran setup:upgrade, then ran setup:di:compile, but nothing changes. Is the example as given in DevDocs omitting something that I should know ?