i'm editing a Magento 2 module. If i install the module via composer require
, then run all the necessary commands, the module works.
If i manually copy the module files from vendor/{vendorname}/{modulename}
to app/code/{vendorname}/{modulename}
, then uninstall the vendor
module via composer+all the necessary commands, then i enable the module present in app/code
with the necessary commands, this is the result:
And this is the resulting system.log
:
[2022-10-21T14:57:47.998332+00:00] main.CRITICAL: Error: Class "Mynamespace\Helper\Data" not found in /var/www/magento2-domain/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
Stack trace:
#0 /var/www/magento2-domain/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject()
#1 /var/www/magento2-domain/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create()
#2 /var/www/magento2-domain/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get()
#3 /var/www/magento2-domain/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Compiled->create()
#4 /var/www/magento2-domain/vendor/magento/framework/View/Element/BlockFactory.php(44): Magento\Framework\ObjectManager\ObjectManager->create()
#5 /var/www/magento2-domain/vendor/magento/framework/View/Layout/Generator/Block.php(272): Magento\Framework\View\Element\BlockFactory->createBlock()
#6 /var/www/magento2-domain/vendor/magento/framework/View/Layout/Generator/Block.php(252): Magento\Framework\View\Layout\Generator\Block->getBlockInstance()
#7 /var/www/magento2-domain/vendor/magento/framework/View/Layout/Generator/Block.php(229): Magento\Framework\View\Layout\Generator\Block->createBlock()
#8 /var/www/magento2-domain/vendor/magento/framework/View/Layout/Generator/Block.php(134): Magento\Framework\View\Layout\Generator\Block->generateBlock()
#9 /var/www/magento2-domain/vendor/magento/framework/View/Layout/GeneratorPool.php(93): Magento\Framework\View\Layout\Generator\Block->process()
#10 /var/www/magento2-domain/vendor/magento/framework/View/Layout.php(365): Magento\Framework\View\Layout\GeneratorPool->process()
#11 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->generateElements()
#12 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent()
#13 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}()
#14 /var/www/magento2-domain/generated/code/Magento/Framework/View/Layout/Interceptor.php(32): Magento\Framework\View\Layout\Interceptor->___callPlugins()
#15 /var/www/magento2-domain/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#16 /var/www/magento2-domain/vendor/magento/framework/View/Page/Builder.php(65): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#17 /var/www/magento2-domain/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#18 /var/www/magento2-domain/vendor/magento/framework/View/Layout.php(271): Magento\Framework\View\Layout\Builder->build()
#19 /var/www/magento2-domain/vendor/magento/framework/View/Layout.php(896): Magento\Framework\View\Layout->build()
#20 /var/www/magento2-domain/vendor/magento/module-cms/Helper/Page.php(216): Magento\Framework\View\Layout->getBlock()
#21 /var/www/magento2-domain/vendor/magento/module-cms/Controller/Index/Index.php(74): Magento\Cms\Helper\Page->prepareResultPage()
#22 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Cms\Controller\Index\Index->execute()
#23 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent()
#24 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}()
#25 /var/www/magento2-domain/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(23): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins()
#26 /var/www/magento2-domain/vendor/magento/framework/App/Action/Action.php(111): Magento\Cms\Controller\Index\Index\Interceptor->execute()
#27 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#28 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cms\Controller\Index\Index\Interceptor->___callParent()
#29 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cms\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}()
#30 /var/www/magento2-domain/generated/code/Magento/Cms/Controller/Index/Index/Interceptor.php(32): Magento\Cms\Controller\Index\Index\Interceptor->___callPlugins()
#31 /var/www/magento2-domain/vendor/magento/framework/App/FrontController.php(245): Magento\Cms\Controller\Index\Index\Interceptor->dispatch()
#32 /var/www/magento2-domain/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#33 /var/www/magento2-domain/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#34 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#35 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#36 /var/www/magento2-domain/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#37 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#38 /var/www/magento2-domain/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#39 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#40 /var/www/magento2-domain/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#41 /var/www/magento2-domain/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#42 /var/www/magento2-domain/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#43 /var/www/magento2-domain/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#44 /var/www/magento2-domain/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#45 {main} [] []
From this log it seems that magento cannot find one of my module's classes, as if the class has not been autoloaded.
So my question is:
How is it possible that the EXACT same module works when placed in the vendor
folder via composer, but doesn't work when manually placed under app/code
??
The module is evidently working when placed in vendor
, hence the code is correct.
Isn't app/code
meant to be used for the live development of modules?? Am i missing something?
Please note: after i moved the module to app/code
i ran the following commands:
composer install
composer dump-autoload
bin/magento module:status
bin/magento module:enable Companyname_Modulename --clear-static-content
bin/magento setup:upgrade
bin/magento setup:di:compile
app/code
. is that correct? how to fix this?