在Pimple 1.0中,我曾经能够像这样共享类实例:
$app['some_service'] = $app->share(function () { return new Service(); });
现在这似乎已被弃用,我无法找到这样做的新方法.
在Pimple 1.0(Silex 1)中,你这样做:
$app['shared_service'] = $app->share(function () { return new Service(); }); $app['non_shared_service'] = function () { return new Service(); };
在Pimple 3.0(Silex 2)中你这样做(这是相反的!):
$app['shared_service'] = function () { return new Service(); }; $app['non_shared_service'] = $app->factory(function () { return new Service(); });