Reputation: 43
I've read Magento's DevDocs and Googled this problem but the usual missing registration.php
answer doesn't apply here.
I'm on the released CE 2.0.0 version and I'm simply trying to enable my first minimum test module in magento/vendor/
but
bin/magento module:enable -c Tchsl_Test
results in:
Unknown module(s): 'Tchsl_Test'
I am basing this on the naming conventions and file positions of modules in vendor/magento/
In vendor/tchsl/module-test/etc/module.xml
I have
<config xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Tchsl_Test" />
</config>
In vendor/tchsl/module-test/registration.php
I have
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Tchsl_Test',
__DIR__
);
What am I missing?
Upvotes: 4
Views: 5163
Reputation: 2350
You don't need to put your module under app/code/
. In app/code/
Magento2 will search and find your module's registration.php
. In Composer's vendor/
dir it doesn't do that, so we need to trick Composer into loading your module's registration.php
.
If you'd check any Magento2 module's composer.json
in vendor/magento/module-*
, you'll see an "autoload"
section which references the registration.php
file. So Composer will autoload your module's registration.php
which will "tell" Magento2 where your module is located.
This is a fragment from the Magento Checkout module's composer.json
:
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Magento\\Checkout\\": ""
}
}
So if you have your module in a separate repository and loaded via composer, then that is the way to go. If you do not have it in a separate repository, then your module does not belong on vendor/
but in app/code/
.
See also this Magento Stack Exchange post.
Upvotes: 0
Reputation: 583
I had this same problem and after some tinkering, discovered that our Modules actually belong under app/code/Tchsl/Test/
. Move your module files there, and running the shell command module:status
should show your disabled module.
Upvotes: 3