0

I am brand new to Magento. I have read the thread at Magento2 CLI module:enable gives error "Unkown module(s)" which details essentially the same issue, though that hasn't exactly helped me in my situation. One of the answers looks potentially useful, mentioning auto-loading via composer json files, but I am unfortunately not finding that information to be clear.

I am wondering if (part of) my issue is path related.

Here is a look at the module I've created, the registration.php, and the command I ran to enable the module.

Again, I am brand new to Magento. I'm not even 100% what I expect to happen upon enabling this test module, though I'd like to get past this particular error. Help is greatly appreciated; please let me know if I can provide more information.

root@magento-1gb-nyc3-01:/var/www/html/magento# cat /var/www/html/magento/vendor/magento/magento2-base/app/code/Training/Test/etc/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="Training_Test" setup_version="2.0.0">
    </module>
</config>
root@magento-1gb-nyc3-01:/var/www/html/magento# cat /var/www/html/magento/vendor/magento/magento2-base/app/code/Training/Test/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Training_Test',
    __DIR__
);
root@magento-1gb-nyc3-01:/var/www/html/magento# pwd
/var/www/html/magento
root@magento-1gb-nyc3-01:/var/www/html/magento# php bin/magento --clear-static-content module:enable Training_Test
Unknown module(s): 'Training_Test'
1
  • The answer by Andrew Noble was correct. I created a code dir under /var/www/html/magento/app and then moved the contents of the Training dir into said code directory. module:enable was then successful. – derek_jenkins Feb 19 '17 at 3:54
1

The issue is where you tried to create your module.

Any modules you write, need to go into the app/code folder. The vendor folder is only used for storing 3rd party modules that are installed via composer.

You should move your code to the following location:

/var/www/html/magento/app/code/Training/Test/etc/module.xml
/var/www/html/magento/app/code/Training/Test/registration.php

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