registration.php
missing
Apparently my Vendorname_Modulename
module was missing the registration.php
. I'm running the latest Magento2 version from GitHub.
Every module has to register itself in the ComponentRegistrar
. A typical registration.php
for a module (in the root of your module) could contain:
<?php
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Vendorname_Modulename',
__DIR__
);
Also see any Magento core component in app/code/Magento/
or your vendor/magento/
dir
registration.php
NOT missing
In addition to this, if you DO have a registration.php
file in your module, but you are still getting this error, this means that your registration.php
was not loaded and Magento2 does not know about your module.
Your module should be under app/code/
(where Magento2 will search folders in app/code/
and find your module's registration.php
), but if you have built your module as a Composer package, it will be in Composer's vendor/
dir and you'll need to trick Composer into loading your module's registration.php
(Magento doesn't search in vendor/
by itself).
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\\": ""
}
}
If you have your module in a separate repository and loaded via composer, then the above 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/
.
If you get the error "Decoding failed: Syntax error" I would check the module's composer.json file. For me this has happened a couple of times due to a comma that is not needed inside the require parameters.
If your composer file has this:
"require": {
"php": "~5.6.0|7.0.2|~7.0.6",
"magento/module-catalog": "101.0.*",
"magento/module-checkout": "100.1.*",
},
You will see this error every time. Instead, remove the comma on your last required value. It should now look like this.
"require": {
"php": "~5.6.0|7.0.2|~7.0.6",
"magento/module-catalog": "101.0.*",
"magento/module-checkout": "100.1.*"
},
I haven't tested but this error would probably happen for each parameter if the last value has a comma at the end.
Best Answer
As you got the same PHP version and everything, i guess that you are just missing dependent vendor packages inside the linux docker container? Try
composer install
command in project root to fix it. Afterwards run the cli command again and it should work. Good luck