Symfony 5: The Fast Track is the best book to learn
modern Symfony development, from zero to production. +300 pages in full color showing how to
combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.
New in version 2.8: The shared option was introduced in Symfony 2.8. Prior to Symfony
2.8, you had to use the prototype scope.
In the service container, all services are shared by default. This means that
each time you retrieve the service, you’ll get the same instance. This is
often the behavior you want, but in some cases, you might want to always get a
In order to always get a new instance, set the shared setting to false
in your service definition: