9

So according to the official documentation, I understand that Magento 2 is PSR-1 and PSR-2 compliant.

I'm wondering if Magento 2 is (or will be) compliant with the others ones ?

  • PSR-3: Logger Interface
  • PSR-4: Autoloading Standard
  • PSR-6: Caching Interface
  • PSR-7: HTTP Message Interface

The answer I expect could also consider the draft PSR

11
  • PSR-3 is already used (with Monolog as default implementation)
  • PSR-4 is already used (via composer)
  • PSR-6 is not supported and I know of no plans to do so, but there is a bridge implementation: https://github.com/EcomDev/magento-psr6-bridge
  • PSR-7 is not supported, and given the current state of Request/Response service contracts is highly unlikely to ever be.

    I tried to build a PSR-7 compatible Request/Response implementation on a recent Hackathon and discovered that it is currently impossible to sanely replace the core implementation. I talked to Lead Architect Anton Kril about it and they are aware of this, but refactoring is not planned yet and will definitely not happen before Magento 2.4. It's not relevant for most users anyway.


About possibly relevant draft PSR:

  • PSR-11 (Container Interop) would be nice to see but I fear that the Magento object manager is too specialized. Again, I know of no plans and it's probably too early to speculate. Update: PSR-11 has been accepted but I still do not believe that it makes sense for Magento, except if they want to support integration of non-Magento packages that come with their own PSR-11 compatible DI container.
  • PSR-14 (Event Manager) is also too new to say anything but Magento would benefit from it IMHO. Let's hope it doesn't take another 5 years to get this approved. Update: No activity regarding PSR-14 on the mailing list and Github since 2016, so this does not seem to move forward since the PHP FIG drama last year where the group almost fell apart.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.