Symfony News

New in Symfony 3.3: PSR-11 containers

Grégoire Paris

Contributed by
Grégoire Paris
in #21265.

Symfony project implements lots of PHP-FIG PSR standards, such as PSR-2 (code styling), PSR-3 (Logger interface), PSR-4 (autoloader), PSR-6 (caching interface) and PSR-16 (simple cache).

Implementing industry standards improves interoperability and reduces the learning curve. That's why in Symfony 3.3 we decided to implement another standard called PSR-11: Container Interface.

PSR-11 defines a simple API that service containers must implement. In practice, this standard won't impact your existing Symfony applications. For starters, the public API only defines two methods called get() and has() which are named and behave in the same way as the Symfony methods that you know and use.

In addition, containers must now implement Psr\Container\ContainerInterface, so we've made our ContainerInterface extend from it. Moreover, the PSR-11 standard defines two new exceptions: ContainerExceptionInterface (implemented by our ExceptionInterface) and NotFoundExceptionInterface (implemented by our ServiceNotFoundException).

Although this new feature won't require any changes in your applications, it will unlock the implementation of other Symfony features, such as better service locators, as explained in an upcoming blog post.

Be trained by Symfony experts - 2017-02-08 Paris - 2017-02-13 Berlin - 2017-02-13 Berlin

About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Find us on Twitter

Find us on Facebook