找到以下位置:
Your Project >> Vendor >> laravel >> framework >> src >> Illuminate >> Container >> Container.php
在以下位置,约340行增加代码
public function singleton($abstract, $concrete = null)
{
$this->bind($abstract, $concrete, true);
}
public function share(Closure $closure)
{
return function ($container) use ($closure) {
// We'll simply declare a static variable within the Closures and if it has
// not been set we will execute the given Closures to resolve this value
// and return it back to these consumers of the method as an instance.
static $object;
if (is_null($object)) {
$object = $closure($container);
}
return $object;
};
}
淘宝优惠券:http://tao.paetao.com/