Commit 8e3642e3 authored by Fabien Potencier's avatar Fabien Potencier

minor #1140 [DOC] Fix, updating documentation by update Pimple #982 (petrgrishin)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

[DOC] Fix, updating documentation by update Pimple #982

Commits
-------

aa3976ce [DOC] Fix, updating documentation by update Pimple #982
parents 63faa187 aa3976ce
......@@ -94,8 +94,19 @@ And to retrieve the service, use::
$service = $app['some_service'];
Every time you call ``$app['some_service']``, a new instance of the service is
created.
As objects are only created when you get them, the order of the definitions does not matter.
Defining Factory Services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
By default, each time you get a service, returns the same instance of it.
If you want a different instance to be returned for all calls, wrap your
anonymous function with the factory() method::
$app['some_service'] = $app->factory(function () {
return new Service();
});
Now, each call to ``$app['some_service']`` returns a new instance of the session.
Access container from closure
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment