yiisoft / yii2-swiftmailer

Yii 2 swiftmailer extension.
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
116 stars 74 forks source link

Extension does not work with composer autoload optimize #75

Closed raoptimus closed 5 years ago

raoptimus commented 5 years ago

If execute composer install with autoload optimize

composer install --no-dev --prefer-dist -o

then extension does not work I have exception:

Too few arguments to function Swift_Mime_SimpleMessage::__construct(), 0 passed

Maybe it could not load dependencies

Additional info

Q A
Yii version 2.0.15
Yii SwiftMailer version 2.1.2
SwiftMailer version
PHP version 7.1, 7.2
Operating system macosx 10.14, ubuntu etc
screen shot 2019-02-06 at 12 17 16
raoptimus commented 5 years ago

Temporary solutions: It needs to add in composer.json

"autoload": {
    "files": [
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/preferences.php"
    ]
  },
machour commented 5 years ago

Would you mind opening a pull request with this change? This will make the approval/discussion/fix happen faster :)

raoptimus commented 5 years ago

Done. https://github.com/yiisoft/yii2-swiftmailer/pull/76

rob006 commented 5 years ago

Too few arguments to function Swift_Mime_SimpleMessage::__construct(), 0 passed

What makes you think that this is autoloader issue?

raoptimus commented 5 years ago

What makes you think that this is autoloader issue?

You can try execute composer install --no-dev --prefer-dist -o and check

rob006 commented 5 years ago

I'm already using this package with optimized autoloader without any trouble.

raoptimus commented 5 years ago

Would you post the versions?

machour commented 5 years ago

I just ran your command on one of my projects without problems. Relevant bits:


$ php -v
PHP 7.3.0 (cli) (built: Dec  7 2018 11:00:11) ( NTS )

$ composer install --no-dev --prefer-dist -o
...
  - Installing yiisoft/yii2 (2.0.16)
  - Installing swiftmailer/swiftmailer (v6.1.3)
  - Installing yiisoft/yii2-swiftmailer (2.1.2)
...
Writing lock file
Generating optimized autoload files
Merging Composer dependencies in the asset package
Updating npm dependencies
$
perfectio commented 5 years ago

I resolved same problem with latest version of composer

vvval commented 5 years ago

Temporary solutions: It needs to add in composer.json

"autoload": {
    "files": [
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php",
      "vendor/swiftmailer/swiftmailer/lib/preferences.php"
    ]
  },

This helped me also

agriboed commented 4 years ago

@raoptimus It's a bit weird: I have the same issue with Symfony, and adding files to autoloading doesn't help... Besides, I got that error only in a production environment.

rawisebits commented 4 years ago

@raoptimus It's a bit weird: I have the same issue with Symfony, and adding files to autoloading doesn't help... Besides, I got that error only in a production environment.

did you update the composer?

agriboed commented 4 years ago

@raoptimus It's a bit weird: I have the same issue with Symfony, and adding files to autoloading doesn't help... Besides, I got that error only in a production environment.

did you update the composer?

root@657efc3c5917:/var/www/html# composer self-update You are already using composer version 1.10.5 (stable channel).

Yes, nothing helps. Also did: $ composer install --no-dev --prefer-dist -o