New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSR-4 loader conflict with older implementation #3852
Comments
Don't know if this is still an issue, but I guess/hope not, so closing. There isn't much we can do anyway IMO. |
This is still the issue. I am a WordPress plugin author too and I receive reports from my users about the error. Conditions are same: WordPress and two plugins using different Composer's The solution is to generate unique |
I don't think that's needed as we only include that file if it isn't declared yet. |
Right. That's why the issue happens:
|
I see, but that's not something we want to fix I think.. if people randomly embed code from composer it's not really going in the direction we want. Both plugins should be installed via composer and then this would not happen.. |
I'm not sure I get you about random composer's code embedding. Both plugins in the example above use composer as it is supposed to: Anyway, I agree that ideally both plugins should be installed with Composer. However, in real life it's not feasible. So, in other words composer is not suitable for embedded projects, like Wordpress plugins. It's sad since it does not seem such a big deal to make Composer working for them too. |
Pretty much every project except wordpress at this point works in the same way: you have a composer.json and declare the list of plugins you want, and they get installed, and that's that. One autoloader, then some plugins/libraries/whatever packages. If every wordpress plugin embeds a composer autoloader, it's because the ecosystem is broken and wordpress core doesn't give a damn about moving forward. It's not something I am willing to waste time on I'm sorry.. As a solution though, I would suggest you try out and spread the word about https://roots.io/bedrock/ - as it provides exactly what I described above for wordpress. |
Almost everything in PHP world is broken, including PHP itself and Wordpress. Thanks for Bedrock. No doubt it's a nice thing. However, as a plugin author I have nothing to do with that. Asking my plugin users to switch to Bedrock is like asking Composer's users switch to Mac OS to able to use it. There is another show stopper though: no support for multiple versions of a library in a single project. Guys in discussion #2609 suggest to rebuild the world to fix it ;) |
I have made a plugin for Composer fixing the initial error. Although, it does not fix all the WordPress issues, it's one step closer to that. Maybe it would be useful for someone like me coming here from google. |
@Rarst JMTCW, but using Composer inside plugins is a bad idea because PHP and WordPress have no way to manage multiple versions of the same code in one site installation. But then you know that. :-) |
So apparently we have no other choice than: A) Create and use a custom fork of composer that can do exactly this Software Development comes from the need of solving real world problems. With any of these options seems that we are creating more problems than solving them, only for not willing to give the final developers the choice of deciding how we want to use this tool. Bad practices will be always there no matter how restrictive we are, all depends on how people uses the tools they have. I am totally agree with @dangoodman and his solution #3852 (comment) with a default to the current behavior of naming it |
Hello from WordPress land with crazy edge case.
The user of one of plugins had reported following error:
The working theory is that another plugin present in the system is also using Composer autoload, but at old pre-PSR-4 version.
The logical attempt was to try optimized autoload, but turns out that despite all the classes getting compiled into classmap file, the PSR-4 instructions are still retained and loaded (thus still causing crash).
cc @dannyvankooten @coenjacobs
The text was updated successfully, but these errors were encountered: