Depends on the version of Pimple!
In Pimple 1.0
$container['shared'] = $container->shared(function(){ return new Class(); }); $container['non_shared'] = function() { return new Class(); };
In Pimple 3.0
$container['shared'] = function() { return new Class(); }; $container['non_shared'] = $container->factory(function() { return new Class(); });
Remembering that when they create a shared service, what they return will not change. When you create a non-shared service, each time you use Pimple will provide you with a new instance of this service.
source share