Bug #57604
closedPackageManager is unable to resolve composer PSR-4 namespaces
0%
Description
Currently the package manager is only able to resolve PSR-0 namespaces.
This makes it impossible to include composer packages which rely on PSR-4 namespaces, such as Pelago\Emogrifier, unless the composer autoloader is included manually in a TYPO3 extension.
Steps to reproduce
Create a composer.json in the root of site path like this:
{ "config": { "vendor-dir": "Packages/Libraries" }, "minimum-stability": "dev" "require": { "pelago/emogrifier": "*" } }
Run "composer install" in the path in order to fetch the package
Ensure typo3conf/PackageStates.php is updated - this can be done by uninstalling and installing a TYPO3 extension.
Activate the package manually by editing PackageStates.php, as it currently isn't possible to activate composer packages through the UI or CLI
Try to instantiate the \Pelago\Emogrifier class which will fail
Updated by Mathias Brodala about 10 years ago
Actually the whole autoloading is a mess. First you have to put your classes into Classes/
since that path is hardcoded and written to the PackageStates.php
. But then you must not actually use psr-0 within that directory but psr-4 instead. If you specify psr-4 instead, the package key is converted from Vendor.Package
to vendor.package
and classes cannot be found anymore.
If you manually fix the casing in the PackageStates.php
, the classes are found again. Funny: if you enter the extension manager then, the package in question shows up twice as Vendor.Package
and vendor.package
. Removing both from PackageStates.php
leaves only vendor.package
again upon next scan.
Summarized for Vendor\Package\Class
:
- psr-0 +
Classes/Vendor/Package/Class.php
: correct, but not found - psr-4 +
Classes/Class.php
: correct, but not found - psr-0 +
Classes/Class.php
: incorrect, but found
Conclusion: Neither psr-0 nor psr-4 are properly supported.
Updated by Peter Niederlag over 9 years ago
- Status changed from New to Needs Feedback
As the composer autoloader was added into the Core with version 6.2.10 this problem might have been solved by now.
Can you please recheck if the problem is still present for you on > 6.2.10?
Please have a look at http://wiki.typo3.org/ComposerClassLoader for more details
Updated by Mathias Brodala over 9 years ago
It seems to work with the current 6.2.11, even without preferring the Composer autoloader.
Updated by Mathias Brodala over 9 years ago
Apparently the important bit is the "type": "typo3-cms-extension"
option in the Composer manifest of the extension. If it is present, the described issue can be avoided.
Updated by Alexander Opitz over 9 years ago
- Status changed from Needs Feedback to Closed