title: How can I use $app in custom classes in Silex?
body: <p>I know this looks like a dupllicate of <a href="https://stackoverflow.com/questions/19565709/inject-silex-app-in-my-custom-class">Inject Silex $app in my custom class</a> and others, but I couldn't get it working from their solutions.</p>
  
  <p>I define my service like this:</p>
  
  <pre><code>$app['user.repo'] = function () {
      return new MyApp\Repository\User();
  };
  </code></pre>
  
  <p>My class looks like this:</p>
  
  <pre><code>&lt;?php
  namespace MyApp\Repository;
  use Silex\Application; 
  
  class User {
      public function findAll(Application $app) {
          $users = $app['db']-&gt;fetchAll('SELECT * FROM user');
          return $users;
      }
  }
  </code></pre>
  
  <p>And I use the service like this:</p>
  
  <pre><code>$users = $app['user.repo']-&gt;findAll($app);
  </code></pre>
  
  <p>How can I do this same thing without putting <code>$app</code> in all my methods?</p>