title: How to include doctrine entity manager to files generated by View?
body: <p>I use mini php MVC. Variables from <code>bootstrap</code> are not included in generated <code>view</code>. I can include <code>entityManager</code> to <code>index.php</code>,
  but i am not able to include <code>entityManager</code> to view files. WHy? How to include doctrine entity manager to files generated by View? </p>
  
  <p>How to include entity manager to <code>_register1Db.php</code> file below?
  The view is displayed properly, it does not show errors that bootstrap.php is not found (if i chaneg path, such an error is displayed), but view does not include entity manager from bootstrap.php</p>
  
  <p>//1. \src\bootstrap.php</p>
  
  <pre><code>use Doctrine\ORM\Tools\Setup;
  use Doctrine\ORM\EntityManager;
  
  $isDevMode = true;
  $entitiesPaths = array(__DIR__.'/CrmBundle/Entity');
  
  $dbParams = array(
    'dbname' =&gt; 'dbname',
    'user' =&gt; 'user',
    'password' =&gt; 'pswd',
    'host' =&gt; 'localhost',
    'driver' =&gt; 'pdo_mysql',
  );   // 'pdo_mysql',
  
  
  $config = Setup::createAnnotationMetadataConfiguration($entitiesPaths, $isDevMode);
  $em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
  
  $some='some';
  </code></pre>
  
  <p>//2. \public\index.php</p>
  
  <pre><code>require_once '../src/bootstrap.php'; //which requires autoload.php
  print_r('&lt;br&gt;&lt;br&gt; index some='.$some); // works
  var_dump($em);  //works
  use core\App;
  $app = new App(); //App from urk identifines controller and action and pass url paramteters to them, controller action analize parameters and displays views, in this case  security\register 
  </code></pre>
  
  <p>//3. src\CrmBundle\Resources\views\security\register.php</p>
  
  <pre><code>include ('_register1Db.php');
  </code></pre>
  
  <p>//4. src\CrmBundle\Resources\views\security_register1Db.php</p>
  
  <pre><code>require_once '/../../../../bootstrap.php';  // 
  var_dump($em);  // Undefined variable: em 
  print_r('&lt;br&gt;&lt;br&gt; register some='.$some); //Undefined variable: some
  </code></pre>
  
  <p>//The way i generate the view: src\core\View.php</p>
  
  <pre><code>ob_start();
  include_once( __DIR__.'/../bootstrap.php' );
  include_once( $this-&gt;viewTemplatePath.$this-&gt;file );
  ob_end_flush();  
  </code></pre>
  
  <p>// view generation with debugging variables from bootstrap.php :  src\core\View.php</p>
  
  <pre><code>    include_once( __DIR__.'/../bootstrap.php' );
      ob_start();
      // think how to render extract variable in order to pass to the file
      include_once( __DIR__.'/../bootstrap.php' );  
      var_dump($em);  //undefined
      print_r('&lt;br&gt;&lt;br&gt; parseViewPhpinside some=' . $some); //undefined
      print_r('&lt;br&gt;&lt;br&gt; parseViewPhpinside __DIR__=' . __DIR__);  // ....apache2\htdocs\own\log\src\core 
      include_once( $this-&gt;viewTemplPath.$this-&gt;file );
      if($store) return ob_get_clean(); 
      else ob_end_flush();
      var_dump($em);  //undefined
      print_r('&lt;br&gt;&lt;br&gt; parseViewPhp some='.$some);  //undefined
  </code></pre>