VSCode is giving an "Undefined Type"
error for the two \Magento\ paths. I installed two Magento extensions (Toolbox, Snippets) but it doesn't help. How do I get VSCode to recognize these paths?
class Index extends \Magento\Framework\App\Action\Action
{
protected $_pageFactory;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $pageFactory
)
{
$this->_pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
return $this->_pageFactory->create();
}
}
Thanks in advance
You need Magento’s source and PHP stubs in VSCode’s workspace so IntelliSense can resolve the classes.
composer install
so vendor/
(with Magento’s framework files) exists."intelephense.environment.includePaths": ["vendor"]
to your settings.json
.