Welcome Guest, Not a member yet? Register   Sign In
Support for psr/log:^2.0
#4

So normally how I would allow multiple versions would be to run all of my automated tests against each release I intend to support, then all that pass can be added to composer.json. So if all 3 psr/log versions pass, then I would create my feature branch against 4.6 branch, then run: composer require psr/log:"^1.0|^2.0|^3.0"

How composer reacts to that would be if the package already exists in composer.lock, it would just keep that version. If not, it would grab the newest version possible out of your defined choices. In other codebases where codeigniter4/framework is required by composer, it would act in the same way. If in composer.lock already, keep that version, otherwise pull in the newest version possible (they may have other dependencies that only work with certain versions, as in my case).

However, I just pulled down the codeigniter4/framework repo down locally to check it out and found something I didn't expect. It appears Codeigniter4 actually overrides psr/log with it's own copy located in system/ThirdParty/PSR/Log via the AutoloadConfig class (system/Config/AutoloadConfig.php). It appears to be a copy of psr/log 3.0 in v4.5.0, and psr/log 1.X in v4.4.8, which makes sense, based off the requirement in composer.json. Based on the comments, it looks like this was done for a slight autoloading performance enhancement for these frequently used classes.

So technically it could work by changing composer.json to allow psr/log 2X or 3.X, but any users who extend codeigniter core classes or change the logger used in any other way would have to ensure the replacement is compliant with the psr/log 3.0 interfaces/traits..... Which would be confusing if the composer.json file said ^2.0|^3.0. The only way to resolve that would be to remove the AutoloadConfig code and let composer natively autoload either version 2.X or 3.X, and I'm not going to ask your or anyone to do that. I assume they were put there for a reason in 2022 because it improved performance. I will take your suggestion and fork the repo so we can get started on the codeigniter 4 migration before our psr/log upgrade is completed. Once our psr/log upgrade is complete, we can switch back to the official repo for CI 4 and drop our fork.

Thanks,
Mike
Reply


Messages In This Thread
Support for psr/log:^2.0 - by mteall - 07-17-2024, 01:37 AM
RE: Support for psr/log:^2.0 - by kenjis - 07-17-2024, 03:54 AM
RE: Support for psr/log:^2.0 - by kenjis - 07-17-2024, 04:10 AM
RE: Support for psr/log:^2.0 - by mteall - 07-17-2024, 10:55 AM
RE: Support for psr/log:^2.0 - by kenjis - 07-17-2024, 01:11 PM
RE: Support for psr/log:^2.0 - by mteall - 07-17-2024, 01:37 PM



Theme © iAndrew 2016 - Forum software by © MyBB