|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #73202 Pass origin (callee) as second parameter to autoloading implementations
Submitted: 2016-09-29 08:54 UTC Modified: 2016-09-29 09:35 UTC
Avg. Score:4.2 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: philippwrann at gmail dot com Assigned:
Status: Wont fix Package: SPL related
PHP Version: Next Major Version OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: philippwrann at gmail dot com
New email:
PHP Version: OS:


 [2016-09-29 08:54 UTC] philippwrann at gmail dot com
At the moment it is not possible to implement dependency managers that can handle different versions of the same package. If the callee (file location) would be provided as second parameter for autoload callbacks a autoloading implementation could determine the correct version to load.

Some real world example:

You start a new composer based project and require some third party package.
That package requires another package, for example some api.

So long all is good

Now you require one more package, that requires the same package but in another version => not possible.

A fix would be downwards compatible because the additional parameter would simply be ignored by current implementations.

Test script:
// something like this 
spl_autoload_register(function($className, $originPath){


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-29 09:13 UTC] philippwrann at gmail dot com
In fact it would be possible at the moment if you use the debug_backtrace() function, but i thats more a hack than a solution.
 [2016-09-29 09:35 UTC]
-Status: Open +Status: Wont fix
 [2016-09-29 09:35 UTC]
debug_backtrace in action:
I'd hardly call two lines of code a "hack" for a feature that is specialized at best and conducive to unexpected bugs at worst.

Regardless, the side-by-side problem needs much more than just a second argument to the autoloader. How will you have multiple versions of the same class available at once? How will PHP know that the same class name needs the autoloader invoked multiple times from different paths, let alone which one's code to execute when a class is referenced?

Not even Windows' SxS solution supports having multiple versions of a library running concurrently for a single application.
 [2016-09-29 09:59 UTC] philippwrann at gmail dot com
Yes, did not think the whole problem through, thanks.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 10 09:01:27 2023 UTC