--- /dev/null
+<?php
+/**
+ * Demonstrates how we register binders so that the instances get created only
+ * when actually accessing the instance.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Injector
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @link http://pear.horde.org/index.php?package=Injector
+ */
+
+require_once 'Horde/Autoloader.php';
+
+/**
+ * A dummy binder.
+ *
+ * @category Horde
+ * @package Injector
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @link http://pear.horde.org/index.php?package=Injector
+ */
+class Binder implements Horde_Injector_Binder
+{
+ /**
+ * Create an instance.
+ *
+ * @param Horde_Injector $injector The injector should provide all required
+ * dependencies for creating the instance.
+ *
+ * @return mixed The concrete instance.
+ */
+ public function create(Horde_Injector $injector)
+ {
+ return 'constructed';
+ }
+
+ /**
+ * Determine if one binder equals another binder
+ *
+ * @param Horde_Injector_Binder $binder The binder to compare against $this
+ *
+ * @return bool true if they are equal, or false if they are not equal
+ */
+ public function equals(Horde_Injector_Binder $binder)
+ {
+ return false;
+ }
+}
+
+$a = new Horde_Injector(new Horde_Injector_TopLevel());
+$a->addBinder('constructed', new Binder());
+var_dump($a->getInstance('constructed'));
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Demonstrates how to use the default factory binder with Horde_Injector.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Injector
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @link http://pear.horde.org/index.php?package=Injector
+ */
+
+require_once 'Horde/Autoloader.php';
+
+class Greet
+{
+ public function __construct($somebody)
+ {
+ $this->somebody = $somebody;
+ }
+
+ public function greet()
+ {
+ print 'Hello ' . $this->somebody;
+ }
+}
+
+class Factory
+{
+ static public function getGreeter(Horde_Injector $injector)
+ {
+ return new Greet($injector->getInstance('Person'));
+ }
+}
+
+$a = new Horde_Injector(new Horde_Injector_TopLevel());
+$a->setInstance('Person', 'Bob');
+$a->bindFactory('Greet', 'Factory', 'getGreeter');
+$a->getInstance('Greet')->greet();
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Demonstrates how to use the default factory binder with Horde_Injector.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Injector
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @link http://pear.horde.org/index.php?package=Injector
+ */
+
+require_once 'Horde/Autoloader.php';
+
+interface Person
+{
+ public function __toString();
+}
+
+class World implements Person
+{
+ public function __toString()
+ {
+ return 'World';
+ }
+}
+
+interface Greeter
+{
+ public function greet();
+}
+
+class Hello implements Greeter
+{
+ public function __construct(Person $somebody)
+ {
+ $this->somebody = $somebody;
+ }
+
+ public function greet()
+ {
+ print 'Hello ' . $this->somebody;
+ }
+}
+
+$a = new Horde_Injector(new Horde_Injector_TopLevel());
+$a->bindImplementation('Person', 'World');
+$a->bindImplementation('Greeter', 'Hello');
+$a->getInstance('Greeter')->greet();
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Demonstrates settings/getting concrete instances.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Injector
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @link http://pear.horde.org/index.php?package=Injector
+ */
+
+require_once 'Horde/Autoloader.php';
+
+$a = new Horde_Injector(new Horde_Injector_TopLevel());
+$a->setInstance('a', 'a');
+var_dump($a->getInstance('a'));