2

I added registration.php to my custom (project specific) modules and themes. But those files do not end up in vendor/composer/autoload_files.php after composer.phar dumpautoload - so the modules are not registered.

How can I make my code in app/code and app/design known to Magento and/or composer to load the registration.php ?

3 Answers 3

4

Not sure if this applies anymore, but I added registration.php for my module (a few minor versions ago), ran php bin/magento setup:upgrade and my module was recognized without touching composer.

[EDIT]
I just tested this on the latest available version (rc) and it works the same.
I add the registration.php file for modules:

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '[Namespace]_[Module]',
    __DIR__
);

and run setup:upgrade and the module is recognized.

For theme I added registration.php:

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/[Namespace]/[theme]',
    __DIR__
);

added theme.xml

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>[Title here]</title>
    <parent>Magento/blank</parent>
    <media>
        <preview_image>media/preview.jpg</preview_image>
    </media>
</theme>

created the media/previw.jpg, cleared the cache and everything works without touching composer.

6
  • Does not seem to work. And be aware that this problem is also happening for Themes, which are not "real modules".
    – Alex
    Commented Nov 9, 2015 at 18:05
  • I found app/etc/NonComposerComponentRegistration.php - but I have no clue from where this should be included.
    – Alex
    Commented Nov 9, 2015 at 18:12
  • Like I said, this worked on an older version. I will try it on a new version and get back with a result.
    – Marius
    Commented Nov 9, 2015 at 18:24
  • @Alex. See my update. It seams to work without touching composer even with the latest version.
    – Marius
    Commented Nov 10, 2015 at 8:37
  • Nope. I think you did not install the full magento via composer like me but used a git clone of the Magento2 main repo?
    – Alex
    Commented Nov 10, 2015 at 15:40
3

registration.php files of non-composer packages are handled by the file

app/etc/NonComposerComponentRegistration.php

This is included here: https://github.com/magento/magento2/blob/22629abe10f9c640fe47b6081d57fedccdea8e0f/composer.json

But it is not included in the product-base repo: https://github.com/magento/magento2-community-edition/blob/master/composer.json nor in https://packages.magento.com/_packages/magento_product-community-edition-2.0.0-rc.zip

So this looks like a bug to me which can be fixed by adding

"autoload": {
    "files": [
        "app/etc/NonComposerComponentRegistration.php"
    ]
},

to your composer.json

1

For me, this worked: delete all files in the pub/static/frontend and var/view_preprocessed directories, then reload the pages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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