What is CI4's PSR Compliance?

Why Interviewers Ask This

Interviewers ask this to evaluate whether you have the depth of knowledge needed to mentor others and lead technical decisions. The expected answer goes beyond definitions into practical implications and real-world consequences.

Answer

CodeIgniter 4 made significant strides toward PSR compliance compared to CI3. CI4 conforms to: PSR-1 and PSR-12 (coding standards), PSR-3 (Logger Interface — CI4's logger implements Psr\Log\LoggerInterface), PSR-4 (autoloading — full Composer PSR-4 support), PSR-7 (HTTP Messages — CI4's Request and Response classes are inspired by PSR-7 but are not fully compliant; they do not extend PSR-7 interfaces), PSR-11 (Container Interface — partially supported via the Services system). The PSR-7 non-compliance means CI4 does not natively work with PSR-15 middleware packages. However, CI4's Filters achieve the same goal internally. Third-party adapters exist to bridge CI4 with PSR-7 middleware ecosystems if needed. CI4 uses PSR-3 logging fully, so Monolog handlers can be integrated easily.

Common Mistake

Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex CodeIgniter answers easy to follow.