3

I installed a local copy of Magento 2 into my XAMPP and have been getting to know the new structure. I have however run into a problem when trying to setup a basic module.

I have created the following file/folder structure

app/code/Heirik/Test/etc/module.xml

Inside this file I have the following

<?xml version="1.0"?>
<config>
    <module name="Heirik_Test" schema_version="2.0.0">
    </module>
</config>

I refreshed the store cache however when I go to store>configuration>advanced the module is not loading into the list. According to the most recent devdocs there is no longer a need to set the module to active inside the XML.

I know that Magento is reading the module.xml because if I remove the schema_version parameter I get an error.

15

With the latest builds of Magento this has changed to

php -f bin/magento module:enable --clear-static-content Module_Name
php -f bin/magento setup:upgrade
|improve this answer|||||
  • Nice update. I marked this as the correct answer as it accurately reflects the current build status. – Eirik May 5 '15 at 2:19
1

After some searching, trial and error I located the following answer

For an existing Magento instance, you'll need to register a custom module as follows:

  1. Edit the app/etc/config.php file and add your module there and specify value "1" (enabled)
  2. Then refresh the cache.

So in my case I had to add

'Heirik_Test' => 1,

Into the Modules array inside app/etc/config.php

|improve this answer|||||
  • This is correct, but may be reworked before GA. The config.php file is relatively new. The modules array is in the required load order. The setup process works out the sequencing so at run time it just has to load the modules in the order of the array. So for now, yes, add your module to the array, but if your module must be loaded before another module you need to put it in the right place. We should make it nicer to add a new module without needing to manually editing config.php. – Alan Kent Dec 28 '14 at 6:45
  • 2
    I recommend to not edit app/etc/config.php by hand as it is now possible to use php -f setup/index.php module-enable Heirik_Test which will sort the modules based on sequence (plus it's safer than editing manually). – Kristof at Fooman Feb 15 '15 at 23:47
  • @fooman at the time of original writing you were not able to. But now you are able to, but thanks for updating the answer. – Eirik Feb 16 '15 at 20:53
  • @Eirik I know - just wanted to make sure that this information gets out there – Kristof at Fooman Feb 16 '15 at 20:57
1

Or even easier, got to Mage install dir and run:

php -f setup/index.php module-enable --modules=MODULENAME
php -f setup/index.php update
|improve this answer|||||
-1

So my issue when trying to get a custom module to register, running Magento 2.2.0 was that the composer generated file vendor/composer/autoload_files.php was not updated when I ran composer update.

It didn't matter what I did, manually adding it to the config.php would make it look like it was working but after running magento setup:upgrade the module was no longer registered and didn't run any install/upgrade scripts.

After updating composer properly and tripple checking it was in the autoload_files, the module registered and I sighed of relief.

Just something to be aware of. Hopefully if anyone else has issues similar, this can shed some light.

|improve this answer|||||
-1

Your module's file named module.xml file config tag should have XML schema and its xsd location which validate your module.xml file structure. Schema value should be like

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.