namespace Cloudways\MyModule\Controller\Index;

use Magento\Framework\App\Action\Action;

use Magento\Framework\App\Action\Context;

use Magento\Framework\View\Element\Messages;

use Magento\Framework\View\Result\PageFactory;  

class Index extends \Magento\Framework\App\Action\Action

    /** @var PageFactory $resultPageFactory */
    protected $resultPageFactory;

     * Result constructor.
     * @param Context $context
     * @param PageFactory $pageFactory
    public function __construct(Context $context, PageFactory $resultPageFactory)
        $this->resultPageFactory = $resultPageFactory;
     * Blog Index, shows a list of recent blog posts.
     * @return \Magento\Framework\View\Result\PageFactory
    public function execute()
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend(__('Custom Front View'));
        return $resultPage;

  • have you remove var/generation folder from root? Commented Apr 5, 2017 at 6:08
  • please let me know if you have issue. Commented Apr 5, 2017 at 6:22
  • Yupp i tried but that folder was unable to remove.
    – user48879
    Commented Apr 5, 2017 at 7:06
  • Its create the issue when you have create new file with __construct method you have to remove var/generation folder to see new changes. Commented Apr 5, 2017 at 7:27
  • I remove var/generation folder but couldn't find any new changes
    – user48879
    Commented Apr 6, 2017 at 6:36

2 Answers 2


it might be space issue. I am getting following error and resolved by removing space.

syntax error, unexpected ' public' (T_STRING), expecting function (T_FUNCTION) in /var/www/html/mage2/app/code/Mymodule/Custommodule/Controller/Index/Index.php on line 6


When you copy code from some web it includes special character in the lines you have to remove these invisible special characters from lines at beginning or ending. where error pointing like:

Parse error: syntax error, unexpected 'class' (T_CLASS) in /opt/lampp/htdocs/mage225/app/code/Progos/ThemeChanges/Observer/Product/Data.php on line 10


Parse error: syntax error, unexpected '$product' (T_VARIABLE) in /opt/lampp/htdocs/mage225/app/code/Progos/ThemeChanges/Observer/Product/Data.php on line 21

Can be resolved by removing all before and after the line.

Your Answer

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