title: Where to place custom code for early initialization of DB session in Laravel?
body: <p>I need to run custom SQL commands to initialize the DB session for my Laravel app.</p>
  <p>The code must be invoked by the framework after Laravel has set up everything (i.e. configuration, DB connection, logging, etc.), but before an actual HTTP request or CLI request is served. Note, the solution must also work, for a CLI command via <code>./artisan &lt;something&gt;</code>.</p>
  <p>In case anybody wonders what code I want to run, here it is</p>
  <pre class="lang-php prettyprint-override"><code>$connection = Schema::connection(null)-&gt;getConnection();
  if ($connection-&gt;getDriverName() == 'mysql') {
      $sql_mode = DB::selectOne('SELECT @@SESSION.sql_mode AS sql_mode');
      DB::statement('SET SESSION sql_mode=\'' . $sql_mode-&gt;sql_mode . ',NO_AUTO_VALUE_ON_ZERO\'');
  }
  </code></pre>
  <p>Where should I add this code to ensure it's run at the needed time?</p>