I am new to Magento, and I am trying to do add my very first module. I tried to follow two tutorials that show how to create a "Hello World" module, which basically shows a 'Hello World!' message on the website; I have installed the sample data. Both sample page and admin page are working fine. What I have been trying is the following:
Create folder Magentoexplorer (http://magentoexplorer.com/how-to-build-hello-world-magento-2-module-from-scratch)
Inside this folder, there is another folder, 'etc', which has the file module.xml inside of it. In the Magentoexplorer folder I have registration.php. The codes are copied from the example in the link I provided, see them at the end of the post.
In windows CMD (I have Magento 2.1.2 installed over WAMP server), I do php magento setup:upgrade. It seems that it's working. I get the message 'please re-run Magento compile command', though. In a forum I read that this may be not necessary in developer mode. But I tried to do it anyway, just in case. I got the message 'Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in C:\wamp64\www\magento\vendor\zendframework\zend-code\src\Scanner\FileScanner.php on line 36'. I tried to go to php.ini and change the memory_limit to 1G. However, the error kept persisting.
In the tutorials they advice to put code in app/code. In the version I downloaded I don't have this folder; for what I understood, my code is instead in the vendor/magento folder. I tried to put my module in first one folder, then in the other (I created app/code folder).
I modified the magento config.php file adding a line at the end with 'Magentoexplorer_Helloworld' => 1'.
When I tried to list the modules (php magento module:status), it didn't appear. I also tried 'php magento module:enable Magentoexplorer_Helloworld', but I got the error Unknown module(s): 'Magentoexplorer_Helloworld', which disappeared after modifying the config.php file, but then I couldn't see the admin page, nor the module.
I am trying to understand what the composer does and how to use it, but in the tutorials they don't put it as a requisite for the module to be shown.
Is the composer necessary for the module to appear and work? I am new to php and Magento, and I am trying to learn by myself and searched everywhere but I still cannot figure out what is happening. Do you see any errors in what I have been trying? Am I missing something?
Code:
registration.php:
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Magentoexplorer_Helloworld',
__DIR__
);
module.xml
<?xml version="1.0"? >
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd" >
<module name="Magentoexplorer_Helloworld" setup_version="1.0.0" / >
</config>
Any help or comment will be much appreciated.
Xavier
php bin/magento setup:upgrade
<?php
code so it treat it as html code