1

this is driving me insane.

I am receiving the following error while running compile:

Fatal error: Cannot declare class Magento\Sales\Model\Order\Pdf\Invoice, because the name is already in use in /home/hucklebo/public_html/vendor/magento/module-sales/Model/Order/Pdf/Shipment.php on line 212

Any pointers how to resolve or debug this this as I can't complete the compilation process after adding new modules.

The compile stops at: Class: /home/hucklebo/public_html/generated/code

Thank you. Magento 2.3.4

2 Answers 2

1

At first sight, it seems that some changes have been made in some files in the vendor directory (which should be avoided).

Open the file vendor/magento/module-sales/Model/Order/Pdf/Shipment.php, and verify that the class name is Shipment. In your case, it might be Invoice instead, which is not normal.

To be sure you are working on a sane vendor directory, you should reset it with composer.

To do so, follow these steps :

  1. Backup your current vendor directory, by renaming it into vendor_old (so you can get back to it if you have some problem, or if you had some development made in it)
  2. Run the command composer install, to reinstall all the composer packages properly
  3. Clear the generated files : rm -rf generated/code/* generated/metadata/*
  4. Try again to compile it : bin/magento setup:di:compile
3
  • thank you, i'll try this. You may be right that this is due to historical changes to the vendor directory
    – zoedanbus
    Commented Nov 22, 2023 at 10:59
  • In that case, you should be careful to either get any changes made in the vendor directory and implement them properly into modules/theme. Or if there are few of them, apply them as patches.
    – Cladiuss
    Commented Nov 22, 2023 at 11:01
  • following this has enabled me to complete the compile process: Open the file vendor/magento/module-sales/Model/Order/Pdf/Shipment.php, and verify that the class name is Shipment. In your case, it might be Invoice instead, which is not normal.
    – zoedanbus
    Commented Nov 22, 2023 at 11:15
0

Running composer install generates:

Verifying lock file contents can be installed on current platform. Your lock file does not contain a compatible set of packages. Please run composer update.

Problem 1 - magento/inventory-composer-installer is locked to version 1.1.0 and an update of this package was not requested. - magento/inventory-composer-installer 1.1.0 requires composer-plugin-api ^1.1 -> found composer-plugin-api[2.3.0] but it does not match the constraint.

Problem 2 - magento/magento-composer-installer is locked to version 0.1.13 and an update of this package was not requested. - magento/magento-composer-installer 0.1.13 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.3.0] but it does not match the constraint.

Problem 3 - dealerdirect/phpcodesniffer-composer-installer is locked to version v0.5.0 and an update of this package was not requested. - dealerdirect/phpcodesniffer-composer-installer v0.5.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.3.0] but it does not match the constraint.

Problem 4 - magento/magento-composer-installer 0.1.13 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.3.0] but it does not match the constraint. - msp/twofactorauth 3.1.2 requires magento/magento-composer-installer * -> satisfiable by magento/magento-composer-installer[0.1.13]. - msp/twofactorauth is locked to version 3.1.2 and an update of this package was not requested.

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.