Project

General

Profile

Actions

Bug #57604

closed

PackageManager is unable to resolve composer PSR-4 namespaces

Added by Jacob Rasmussen about 10 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
System/Bootstrap/Configuration
Target version:
-
Start date:
2014-04-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #54491: PackageManager doesn't solve/recognize real composer packages Rejected2013-12-18

Actions
Related to TYPO3 Core - Task #64361: Improve class loading performanceClosed2015-01-19

Actions
Actions #1

Updated by Mathias Brodala over 9 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.

Actions #2

Updated by Peter Niederlag about 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

Actions #3

Updated by Mathias Brodala about 9 years ago

It seems to work with the current 6.2.11, even without preferring the Composer autoloader.

Actions #4

Updated by Mathias Brodala about 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.

Actions #5

Updated by Alexander Opitz almost 9 years ago

So we can close this issue?

Actions #6

Updated by Mathias Brodala almost 9 years ago

Yes, works for me.

Actions #7

Updated by Alexander Opitz almost 9 years ago

  • Status changed from Needs Feedback to Closed
Actions

Also available in: Atom PDF