more refactoring for dependency injection.

This commit is contained in:
Taylor Otwell
2011-08-24 23:44:50 -05:00
parent 6a8aafc259
commit 82045e20d9
10 changed files with 119 additions and 63 deletions

View File

@@ -41,6 +41,14 @@ class Container {
/**
* Register a dependency as a singleton.
*
* Singletons will only be instantiated the first time they are resolved. On subsequent
* requests for the object, the original instance will be returned.
*
* <code>
* // Register a dependency as a singleton
* $container->singleton('user', function() { return new User; })
* </code>
*
* @param string $name
* @param Closure $resolver
* @return void
@@ -53,6 +61,14 @@ class Container {
/**
* Register an instance as a singleton.
*
* This method allows you to register an already existing object instance with the
* container as a singleton instance.
*
* <code>
* // Register an object instance as a singleton in the container
* $container->instance('user', new User);
* </code>
*
* @param string $name
* @param mixed $instance
* @return void