I am not very experienced in Magento 2 development and am maintaining a payment plugin developed by someone else. So far, it has usually worked and I have been able to fix the problems and enhancements that were necessary.
Now with Magento 2.4.2 the plugin has stopped working and I just can't find the reason. I've checked the various change logs but could find nothing that would solve my problem.
The plugin contains several payment methods that are implemented as plugins of their own, and they all talk to a general payment plugin that provides some common functionality (myCompany\myPayment in the examples below). This base plugin somehow is not visible anymore from the other plugins. I am getting the below errors.
When going to the checkout page in the frontend:
main.CRITICAL: Error: Class ‘myCompany\myPayment\Gateway\Config\Config’ not found in /bitnami/magento/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
(I develop on a Bitname Magento 2.4 docker container)
In the backend when trying to open the payment methods page:
main.CRITICAL: Error: Class ‘myCompany\myPayment\Block\Adminhtml\System\Config\Fieldset’ not found in /bitnami/magento/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121
The myPayment plugin is referenced in the module.xml of the specific payment plugins, like this (Creditcard, for instance):
<?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="myCompany_myCreditCard" setup_version="5.1.1">
<sequence>
<module name="Magento_Customer"/>
<module name="Magento_Payment"/>
<module name="Magento_Checkout"/>
<module name="Magento_Quote"/>
<module name="myCompany_myPayment"/>
</sequence>
</module>
</config>
Also, it is referenced in the global composer.json file:
"autoload": {
"files": [
"my-payment/registration.php",
"my-credit-card/registration.php"
],
"psr-4": {
"myCompany\\myPayment\\": "my-payment",
"myCompany\\myCreditCard\\": "my-credit-card"
}
}
Is anyone aware of breaking changes in 2.4.1 or 2.4.2 (in 2.4.0 it works) that could cause this?
Am I missing anything else? Any hints?
Thanks a lot!
1 Answer 1
Vendor and Module names must be camelcase and all files should be placed in corresponding directories that are compatible with your namespace. That's a PSR-4 requirement.
Please change your names on all places:
myCompany=>MyCompanymyPayment=>MyPayment
Your module must live inside app/code/MyCompany/MyPayment directory.
MyCompany\MyPayment\Block\Adminhtml\System\Config\Fieldset class must be placed here: app/code/MyCompany/MyPayment/Block/Adminhtml/System/Config/Fieldset.
You don't want to write your module name inside same module dependency sequence because it will lead you to circular dependency exception.
-
Thanks @dudzio. It seems the path was the problem. The camelcase thing was only a problem with my example posted here, since I changed the class names.Michael Heumann– Michael Heumann2021年06月04日 14:23:29 +00:00Commented Jun 4, 2021 at 14:23
-