Skip to content

Commit 32be441

Browse files
committed
Merge branch 'patch-2' of https://github.com/deleugpn/docs into deleugpn-patch-2
2 parents 93d5e60 + a7306a2 commit 32be441

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

container.md

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [The Make Method](#the-make-method)
1111
- [Automatic Injection](#automatic-injection)
1212
- [Container Events](#container-events)
13+
- [PSR-11](#psr-11)
1314

1415
<a name="introduction"></a>
1516
## Introduction
@@ -251,3 +252,21 @@ The service container fires an event each time it resolves an object. You may li
251252
});
252253

253254
As you can see, the object being resolved will be passed to the callback, allowing you to set any additional properties on the object before it is given to its consumer.
255+
256+
<a name="psr-11"></a>
257+
## PSR-11
258+
259+
Laravel's service container is compliant with PSR-11. The method `has` is an alias for `bound` and will answer whether an identifier is known to the container or not. As for the implementation of `get`, it will be slightly different than `resolve` because it will not offer auto-wiring. Calling `get` with an unknown identifier will still throw an exception even if the identifier is a concrete class.
260+
261+
namespace Some\Package;
262+
263+
class Foo
264+
{
265+
//
266+
}
267+
268+
// Throws Psr\Container\Exception\NotFoundExceptionInterface
269+
$foo = $this->app->get(Foo::class);
270+
271+
// $foo is auto-wired into an instance of Foo
272+
$foo = $this->app->resolve(Foo::class);

0 commit comments

Comments
 (0)