title: Changing storage path before config is initialised but still using env()
body: <p>Setting up a IIS server that is going to run Laravel. Need to set storage path to point to a network drive that is mapped to Z:</p>
  
  <p>As I need this to be configurable, I would like to do this through <code>.env</code> file.</p>
  
  <p>I tried setting it through <code>AppServiceProvider</code> using something like <code>$app-&gt;useStoragePath(config('app.storage_path'));</code>.</p>
  
  <p>This did set the storage path to the required directory when <code>dump(storage_path())</code> is used. But, the issue is that the filesystem config is set before the <code>AppServiceProvider</code> changes the directory. So in the end <code>Storage::disk()</code> uses the default directory for storage.</p>
  
  <p>What I then tried was putting the <code>$app-&gt;useStoragePath(env('APP_STORAGE_PATH', storage_path()));</code> inside <code>bootstrap/app.php</code> file. Obviously this doesn't work as the <code>env()</code> function always returns <code>null</code> here. I realized that Laravel has not initialized the <code>\Dotenv\Dotenv</code> package so its not reading the <code>.env</code> file.</p>
  
  <p>To fix this issue I added this code to <code>bootstrap/app.php</code> - </p>
  
  <pre><code>/**
   * Initializing dotenv here, because we need configurable storage path
   */
  $dotEnv = new \Dotenv\Dotenv(__DIR__ . '\\..\\');
  $dotEnv-&gt;load();
  $app-&gt;useStoragePath(env('APP_STORAGE_PATH', storage_path()));
  </code></pre>
  
  <p>This does work, but Im not sure if this is the best solution as Laravel probably initializes the <code>.env</code> again at some point. So I was wondering if this is a good solution? Or is there a better one?</p>
  
  <p>Thanks for replies!</p>