I'd like to apologize in advance: I'm not a Portuguese speaker, I'm just using Google Translate to translate my answer.
As other people have indicated that you seem to be reading the documentation for Silex 1.x, but what you have installed is Silex 2.x.
One of the major differences between the two versions is that the dependency injection container that Silex uses - Pimple - was embedded in Silex itself in 1.0, while in 2.0 it is treated as a separate application (and probably this is a good idea). Share
is actually a Pimple method, not a Silex method.
Well, I say it's a Pimple method ... it was a Pimple method. In Pimple 1.x, all dependencies were transient objects, unless you specifically used the share
method to make it a singleton. In the current version of Pimple (3.x), the default has been changed and all dependencies are automatically singletons by default, so the share
method is redundant.
What you need to do is follow the Silex 2.x and Pimple 3.x documentation when configuring your application.
References:
(Silex 1.x / Pimple 1.x) By default, each time you receive a service, Pimple returns a new instance. If you want the same instance to be returned for all calls, wrap its anonymous function with the share()
method
(Silex 2.x / Pimple 3.x) By default, each time you receive a service, Pimple returns the same instance.