php DI container
<p>i don´t have a lot of php experience i'd need some help,
i have a php MVC framework,
i use this class:</p>

<pre><code>    class Registry {


private $objects;

private $settings;

    public function __construct() {

    }


    public function iniObject($class, $key)
    {
      $this-&gt;objects[ $key ] = new $class( $this );
    }

    public function getObject( $key )
    {

     return $this-&gt;objects[ $key ];
    }

    public function storeSetting( $setting, $key )
    {

      $this-&gt;settings[ $key ] = $setting;
    }


    public function getSetting( $key )
    {

      return $this-&gt;settings[ $key ];
    }
}
</code></pre>

<p>then i pass the registry to the other classes like:</p>

<pre><code>    Class Controller 
 {

/*
 * @registry object
 */
    protected $registry;

    function __construct(Registry $registry) 
    {

     $this-&gt;registry = $registry;
    //i can use any class from my registry class like the logger class  below
     $this-&gt;registry-&gt;getObject('log')-&gt;write_log('debug', "Controller Class Initialized");
    }

/**
 * @all controllers must contain an index method
 */
    public function index() {}
 }
</code></pre>

<p>i start my bootstrap.php with</p>

<pre><code>$registry = new Registry();

// Instantiate some classes


$registry-&gt;iniObject( 'Utf8', 'utf8');

$registry-&gt;iniObject( 'Uri', 'uri');

$registry-&gt;iniObject( 'Router', 'router');

i get any method like:


$registry-&gt;getObject('router')-&gt;_set_routing();
</code></pre>

<p>and i get a view like:</p>

<pre><code>$registry-&gt;getObject('output')-&gt;_display('myview');
</code></pre>

<p>in this way i can use all the classes inside other classes
passing the registry class like DI constructor, works well,
few code and fast execution,</p>

<p>i've been reading about DI containers and other things,
i'd like to know a better ways to do this, if the registry gets
bigger and bigger how will affect the framework i mean i pass
all the registry to every class, there´s a way to pass just
dependencies that every class needs instead the full registry,
is the registry the best way to work with objects cos allow me
to use any class inside any other class or you thing this isn´t a good
way to do it, any recommendation about DI containers libraries,
please i'd like to recieve ideas from more experienced php
programmers to do this
thanks a lot</p>
