[2.0] changed services to be shared by default#83
Merged
Conversation
Contributor
|
👍 |
|
good idea! |
|
Seems eminently sensible. +1 |
Contributor
|
👍 |
Contributor
|
👍 The README should be updated accordingly. |
Contributor
|
👍 |
Contributor
|
good idea. |
fabpot
added a commit
that referenced
this pull request
Nov 11, 2013
This PR was merged into the master branch. Discussion ---------- [2.0] changed services to be shared by default Now that we have several years of experience using Pimple, I think everyone agrees that having to call `share` everytime you need to define a service is cumbersome. And it is even error-prone when calling `extend` as one needs to call `share` again. #62 proposes a shortcut for the extend use case, but I want to go one step further in Pimple 2.0: remove the need to call `share` altogether. The reasoning is quite simple: services are 99.9% shared (I don't even have an example for a prototype service). So, this PR makes closure shared by default. If you need to define a prototype service, call `prototype`. This change is almost backward compatible as the `share` method is kept as a no-op method. The only BC break is if you have a prototype service in which case you need to wrap it with a `prototype` call. Of course, Pimple 2.0 will be used in Silex 2.0, which will make things much easier to read and shorter. TODO: - [x] update docs and website for 2.0 Commits ------- e5309ac changed services to be shared by default
Contributor
|
@fabpot I just thought of an extra improvement to avoid mistakes: is it possible that extending a prototype service would automatically mark it as a prototype too ? currently, it requires wrapping it again in a |
Contributor
|
and you should tag a 1.x release just before this merge IMO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that we have several years of experience using Pimple, I think everyone agrees that having to call
shareeverytime you need to define a service is cumbersome. And it is even error-prone when callingextendas one needs to callshareagain.#62 proposes a shortcut for the extend use case, but I want to go one step further in Pimple 2.0: remove the need to call
sharealtogether.The reasoning is quite simple: services are 99.9% shared (I don't even have an example for a prototype service).
So, this PR makes closure shared by default. If you need to define a prototype service, call
prototype.This change is almost backward compatible as the
sharemethod is kept as a no-op method. The only BC break is if you have a prototype service in which case you need to wrap it with aprototypecall.Of course, Pimple 2.0 will be used in Silex 2.0, which will make things much easier to read and shorter.
TODO: