Make Zend Framework 2 packages out-of-the-box compatible with TYPO3 Flow
At the moment it's not possible to just use a composer dependency to get a ZF2 package running within Flow (Zend Mail f.e. https://packagist.org/packages/zendframework/zend-mail ). Flow seems to do some "reflecting magic" that results in some nice errors.
Maybe you can copy the packages, create a Package.php and set "$objectManagementEnabled = FALSE" but this is really dirty. There should be a comfortable way to integrate ZF2 packages via composer and just use it like in the followingn example (maybe be disabling object management functions for some Packages in Settings.yaml:
$mail = new \Zend\Mail\Storage\Mbox(array('filename' => 'catcontent.mbox'));
The well known Settings.yaml-option "TYPO3:Flow:object:excludeClasses:" unfortunately does not work here.
PHP Fatal error: Class 'Zend\ServiceManager\AbstractPluginManager' not found in /Users/bernd/Sites/Testproject/Packages/Libraries/zendframework/zend-mail/Zend/Mail/Protocol/SmtpPluginManager.php on line 21
Execution of subprocess failed with exit code 255 and output:
Fatal error: Class 'Zend\ServiceManager\AbstractPluginManager' not found
on line 21
The erroneous command was:
"/opt/local/bin/php" -c '/opt/local/etc/php54/php.ini'
Exception code #1355480641
File /Users/bernd/Sites/Testproject/Packages/Framework/TYPO3.Flow/Classes/TYPO3/Flow/Core/Booting/Scripts.php line 552
Exception reference #201302120924552d1193
Updated by Bastian Waidelich over 7 years ago
- Category changed from AOP to Object
- Status changed from Accepted to Closed
If you take a close look to the exception message:
PHP Fatal error: Class 'Zend\ServiceManager\AbstractPluginManager' not found in Packages/Libraries/zendframework/zend-mail/Zend/Mail/Protocol/SmtpPluginManager.php on line 21 [...]
The actual issue is not related to some "reflecting magic" of Flow, but to the ZF Mail package not correctly defining their dependency. In this case The "SmtpPluginManager" relies on the "ServiceManager" package to be installed.
So in order to fix this, you simply need to install that one, too.
After that you might get some reflection related exception. In my case:
Fatal error: Cannot use ArrayObject as ArrayObject because the name is already in use in Packages/Libraries/zendframework/zend-stdlib/Zend/Stdlib/ArrayStack.php
This can be fixed as described above in the Settings.yaml of the distribution or of the package that requires the ZF packages:
TYPO3: Flow: # disable reflection for non psr-0 compliant 3rd party packages object: excludeClasses: 'zendframework.zendservicemanager' : ['.*'] 'zendframework.zendstdlib' : ['.*']
This works for me. To be sure, you can add the other ZF packages, too ('zendframework.zendloader', 'zendframework.zendmime' & 'zendframework.zendmail').