title: Using monorepo with Symfony project
body: <p>I am trying to move few of my Symfony projects into one monorepo. This is my structure.</p>
  <pre><code>packages/
  ├─ symfony-project-1/
  │  ├─ public/
  │  │  ├─ index.php
  │  ├─ composer.json
  ├─ symfony-project-2/
  │  ├─ public/
  │  │  ├─ index.php
  │  ├─ composer.json
  vendor/
  composer.json
  </code></pre>
  <p>I use package <code>symplify/monorepo-builder</code> to merge all of my project's <code>composer.json</code> file into the root one. Then I split my packages to READ-ONLY repositories.</p>
  <p>To production, I would like to deploy the READ-ONLY repository. So for example, only the content of the directory <code>symfony-project-1</code> would be transferred to the production server and the <code>vendor</code> folder would be installed directly to the same directory. Here comes the problem.</p>
  <p>How can I make the front-controller <code>index.php</code> load <code>./../../../vendor</code> in development and <code>./../vendor</code> in production?</p>
  <p>The <code>index.php</code> looks normally like this:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  // public/index.php
  use App\Kernel;
  
  require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
  
  return function (array $context) {
      return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
  };
  </code></pre>
  <p>I tried this:</p>
  <pre class="lang-php prettyprint-override"><code>...
  
  if (is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
      $autoloadPath = dirname(__DIR__).'/vendor/autoload_runtime.php';
  } else {
      $autoloadPath = dirname(__DIR__).'/../../vendor/autoload_runtime.php';
  }
  
  require_once $autoloadPath;
  
  ...
  </code></pre>
  <p>But then Symfony tries to read <code>.env</code> file from the root of the monorepo not the project root (I get this: <code>Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the &quot;/Users/xxx/work/monorepo/.env&quot; environment file.</code>).</p>
  <p>How to solve this in monorepo?</p>