title: How to connect to database from custom files/classes in Silex
body: <p>I'm trying this mini framework for the first time and this is my first time at all using justa a framework:)<br>
  I added the doctrine service to my index.php file like this:</p>
  
  <pre><code>$app-&gt;register(new Silex\Provider\DoctrineServiceProvider(), array(
      'db.options' =&gt; array(
          'driver'   =&gt; 'pdo_sqlite',
          'path'     =&gt; __DIR__.'/../include/database.sqlite',
      ),
  ));
  </code></pre>
  
  <p>and I create a new file with a class with a static method that resturn an array, for example.</p>
  
  <pre><code>&lt;?php
  
  namespace MyNameSpace;
  
  
  class myClass{
  
      static function getStuff(){
  
  
         return array(1 =&gt; array('foo'=&gt; 'bar',
                                 'bar' =&gt; 'foo',
                                )
                     );
  
      }
  
  }
  </code></pre>
  
  <p>As you can see it's hardcoded so I decide to use a database (sqlite is enought) but I don't know how to get access to $app variable inside my file.</p>
  
  <p>On the other way, all the tutorials that I can find online are confusing and referred to a old Silex's version with the .phar file that now is deprecated, and the directory structures of all examples I found are differente from mine (taken from the fat Silex zip file)</p>
  
  <p>The directory structure of my project is this:</p>
  
  <pre><code>├── composer.json
  ├── composer.lock
  ├── src
  │   └── MyNameSpace
  │       └── myClass.php
  ├── vendor
  │   └── composer
  │   └── doctrine
  │   └── silex
  │   └── ...
  │   └── **autoload.php**
  └── web
      └── css
      └── img
      └── js
      └── views
      └── .htaccess
      └── index.php
  </code></pre>