Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
aa3976ce
Commit
aa3976ce
authored
Apr 10, 2015
by
Petr Grishin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DOC] Fix, updating documentation by update Pimple #982
parent
3e2f70ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
doc/services.rst
doc/services.rst
+13
-2
No files found.
doc/services.rst
View file @
aa3976ce
...
...
@@ -104,8 +104,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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment