Questions tagged [psr-11]

PSR-11 defines a standard for Container interfaces for PHP libraries or frameworks

The goal set by ContainerInterface is to standardize how frameworks and libraries make use of a container to obtain objects and parameters See http://www.php-fig.org/psr/psr-11/

5 questions
4
votes
3 answers

Dependency injection in PHP (slim, php-di)

I have a Slim Php (slim4) application to which I added Monolog for logging purposes. I'm adding the logger to the application like this: $containerBuilder->addDefinitions([ LoggerInterface::class => function (ContainerInterface $c) { $logger…
S. Roose
  • 1,398
  • 1
  • 12
  • 27
2
votes
1 answer

Why doesn't PHP PSR-11 Container provide methods to set dependencies?

if I develop a library that wants to take advantage of a Dependency Container I think that the container implementation (php-di, symfony/dependency-injection, etc.) should be decided by the library's user that, eventually, passes it to me, for…
cheeghi
  • 65
  • 1
  • 4
1
vote
0 answers

What are the reasons for PHP Frameworks to use a Dependency Injection Container for object instantiation?

I am going to focus on Zend Framework, becasue I know it best, but this is certainly applicable to other similar mechanisms found in other PHP Frameworks that use an Inverstion of Control container. In case of Zend Framework, with a bit of…
Dennis
  • 7,907
  • 11
  • 65
  • 115
0
votes
3 answers

Inject container in controller class

I'm migrating my app from Slim/3 to Slim/4. Perhaps I'm confused because there're endless syntaxes for the same stuff but I composed this: use DI\Container; use Slim\Factory\AppFactory; use Slim\Psr7\Request; use Slim\Psr7\Response; require…
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
0
votes
1 answer

php error at runtime Interface 'Psr\Container\ContainerInterface' not found

I recently uploaded a new dependency to a PHP app I am working on and I am now continually getting the following error in Postman Fatal error: Interface 'Psr\Container\ContainerInterface' not found…
NightHawk95
  • 163
  • 3
  • 11