title: laravel - dependency injection and the IoC Container
body: <p>I'm trying to wrap my head around dependency injection and the IoC container and i'm using my UserController as an example. I'm defining what the UserController depends on in its constructor and then am binding those objects to it using App::bind(). If i'm using the Input::get() facade/method/thing am i not taking advantage of the Request object i just injected into it? Should i be using the following code instead, now that the Request object is injected or doesInput::get() resolve to the same Request instance? I'd like to use the static facades but not if they resolve to un-injected objects.</p>
  
  <pre><code>$this-&gt;request-&gt;get('email');
  </code></pre>
  
  <p>Dependency injection</p>
  
  <pre><code>&lt;?php
  App::bind('UserController', function() {
      $controller = new UserController(
          new Response,
          App::make('request'),
          App::make('view'),
          App::make('validator'),
          App::make('hash'),
          new User
      );
      return $controller;
  });
  </code></pre>
  
  <p>UserController</p>
  
  <pre><code>&lt;?php
  class UserController extends BaseController {
  
  protected $response;
  protected $request;
  protected $validator;
  protected $hasher;
  protected $user;
  protected $view;
  
  public function __construct(
      Response $response,
      \Illuminate\Http\Request $request,
      \Illuminate\View\Environment $view,
      \Illuminate\Validation\Factory $validator,
      \Illuminate\Hashing\BcryptHasher $hasher,
      User $user
  ){
      $this-&gt;response = $response;
      $this-&gt;request = $request;
      $this-&gt;view = $view;
      $this-&gt;validator = $validator;
      $this-&gt;hasher = $hasher;
      $this-&gt;user = $user;
  }
  
  public function index()
  {
      //should i use this?
      $email = Input::get('email');
      //or this?
      $email = $this-&gt;request-&gt;get('email');
  
      //should i use this?
      return $this-&gt;view-&gt;make('users.login');
  
      //or this?
      return View::make('users.login');
  }
  </code></pre>