title: Is it dependency injection and is it a bad practice?
body: <p>I have a small framework and I coded it like this. I'm not sure if it is called dependency injection or not. I don't know if it is like a design pattern or not. I also don't know and wonder if passing <code>$this</code> as param is a bad practice.</p>
  
  <p>Have a look at this; (Not a working example, just wrote those codes into browser for explanation.)</p>
  
  <pre><code>/* This is engine model */
  require_once('Database.class.php');
  require_once('Image.class.php');
  require_once('Misc.class.php');
  require_once('BBCode.class.php');
  
  class FrameWork_Engine_Model
  {
      public $database, $config, $misc, $bbcode, $controller, $image;
  
      function __construct($config)
      {
              $this-&gt;database = new Database($configParams);
              $this-&gt;image = new Image($this);
              $this-&gt;misc = new Misc($this);
              $this-&gt;bbcode = new BBCode($this);
              $this-&gt;controller = new Controller($this); //here I call Register controller depending on routing, in this case, register controller.
      }
   ...
   }
  </code></pre>
  
  <hr>
  
  <pre><code> /* This is register controller */
   class Register extends Base_Controller
   {
         /*I can access anything over Engine Model in my controllers */
         $this-&gt;engine-&gt;database-&gt;query(); //I access database model
         $this-&gt;engine-&gt;bbcode-&gt;tag('you'); //I access bbcode model
         $this-&gt;engine-&gt;image-&gt;sanitizeUploadedFile(); //I access image model
  
         //etc. I can access others models like this.
   }
  </code></pre>
  
  <p>Basically, my controllers can access any models via engine model. I believe <code>dependency injection is all about injecting dependencies into controllers?</code> Like, my register controller needs a database model, routing model, and templating model to work. Here it has everything it depends on. Am I mistaken?</p>
  
  <p>With those said, my questions are:</p>
  
  <ol>
  <li><p>Is it a valid dependency injection example? If not, what it is? Does it have a name in design patterns?</p></li>
  <li><p>If it is nothing related to dependency injection, what changes needs to be done to be DI?</p></li>
  <li><p>Is passing <code>$this</code> parameter on newly created classes is a bad practise? If so, why?</p></li>
  </ol>
  
  <p>Ps. I know asking 3 questions in a topic isn't something stackoverflow likes, but I don't want to copy paste entire text to ask them.</p>