magento2: Magento code generation bug, resulting in mails not sending!

Preconditions

  1. Have Magento 2.1.12 installed
  2. PHP 7.0.26
  3. MySQL 5.6

Steps to reproduce

  1. Install https://github.com/Bogardo/Mailgun-Magento2 extension
  2. Run setup:upgrade, di:compile and flush all cache
  3. Configure the extension
  4. Try and send a mail (order mail, invoice mail or any other mail)

Expected result

  1. The mail should send correctly

Actual result

  1. The mail does not send correctly, the following error is written to the logs:
2018-03-02 17:18:53] main.ERROR: Source class "\Nyholm\Psr7\Factory\Stream" for "Nyholm\Psr7\Factory\StreamFactory" generation does not exist. [] []

For some extra information see the following issues: https://github.com/mailgun/mailgun-php/issues/452 https://github.com/php-http/discovery/issues/105

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Well,

Source class “\Nyholm\Psr7\Factory\Stream” for “Nyholm\Psr7\Factory\StreamFactory” generation does not exist.

is literally saying that the class does not exist.

By convention I mean that coding in Magento ecosystem you should know how classes like Nyholm\Psr7\Factory\StreamFactory are treated by Magento autoloader. This is described, for example, here: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/factories.html#writing-factories

I don’t see what can be fixed here on Magento side, as I described earlier https://github.com/Bogardo/Mailgun-Magento2 should not use non-Magento components like https://github.com/php-http/discovery directly, they should be wrapped in some custom factory or adapter in your module.