I am new to Magento and I tried this tutorial where I will create a controller for Magento 2. https://www.mageplaza.com/magento-2-module-development/how-to-create-controllers-magento-2.html
My problem is: When I try to go to the http://<yourbrowser>/helloworld or http://<yourbrowser>/helloworld/index/index, it renders a blank page.
I followed everything from the tutorial, just I renamed the /vendorName/moduleName to /custom/helloWorld
Here are the codes: app/code/custom/helloWorld/etc/frontend/routes.xml
<?xml version="1.0" ?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> <router id="standard"> <route frontName="helloworld" id="helloworld"> <module name="custom_helloWorld"/> </route> </router> </config> app/code/custom/helloWorld/Controller/Index/Index.php
<?php namespace custom\helloWorld\Controller\Index; 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(); //Pagefactory is used to initialize the layout. } } app/code/custom/helloWorld/view/frontend/layout/helloworld_index_index.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <referenceContainer name="content"> <block class="custom\helloWorld\Block\Index" name="helloworld_index_index" template="custom_helloWorld::index.phtml" /> </referenceContainer> </page> app/code/custom/helloWorld/Block/Index.php
<?php namespace custom\helloWorld\Block; class Index extends \Magento\Framework\View\Element\Template { } app/code/custom/helloWorld/view/frontend/templates/index.phtml
<h2>Welcome to HELLO WORLD PAGE!</h2> I already tried to flush the cache but same problem occur.
I hope you can help me. Thank you so much in advance!!
UPDATE: So I just copied whatever is in the link: https://www.mageplaza.com/magento-2-module-development/how-to-create-controllers-magento-2.html
And still renders a blank page...
php bin/magento s:up&&php bin/magento s:s:d -f???