title: Why cant Eloquent in my App Engine app connect to my Google SQL instance?
body: <p>Oddly enough, I can connect to my Google SQL instance from PHPStorm's database tool, just can't seem to connect locally when deployed.</p>
  
  <p>And when I develop locally - my app connects to my local stack instance (docker) fine using the environment variables below.</p>
  
  <p>Here's my <code>app.yaml</code></p>
  
  <pre><code>runtime: php72
  api_version: 1
  
  handlers:
  - url: /.*
    script: public/index.php
  
  env_variables:
    MYSQL_DSN: "mysql:unix_socket=/cloudsql/project:location:sql-instance;dbname=databaseName"
    MYSQL_USER: "username"
    MYSQL_PASSWORD: "password"
  
  runtime_config:
    enable_stackdriver_integration: true
  </code></pre>
  
  <p>And here's how I'm initializing this in Eloquent / Illuminate.</p>
  
  <pre><code>    use Illuminate\Database\Capsule\Manager;
  
      $db = [];
      if(getenv("MYSQL_DSN")){
          $db = [
              'driver' =&gt; 'mysql',
              'dsn' =&gt; getenv("MYSQL_DSN"),
              'username' =&gt; getenv("MYSQL_USER"),
              'password' =&gt; getenv("MYSQL_PASSWORD"),
              'charset'   =&gt; 'utf8',
              'collation' =&gt; 'utf8_unicode_ci',
              'prefix'    =&gt; '',
          ];
      } else if(getenv("MYSQL_HOST")){
          $db = [
              'driver' =&gt; 'mysql',
              'host' =&gt; getenv("MYSQL_HOST"),
              'database' =&gt; getenv("MYSQL_DATABASE"),
              'username' =&gt; getenv("MYSQL_USER"),
              'password' =&gt; getenv("MYSQL_PASSWORD"),
              'charset'   =&gt; 'utf8',
              'collation' =&gt; 'utf8_unicode_ci',
              'prefix'    =&gt; '',
          ];
      }
  
      $settings = [
              // Slim Settings
              'determineRouteBeforeAppMiddleware' =&gt; false,
              'displayErrorDetails' =&gt; true,
              'db' =&gt; $db
          ];
  
      $container = $this-&gt;getContainer();
      $capsule = new Manager;
      $capsule-&gt;addConnection($settings['db']);
  
      $capsule-&gt;setAsGlobal();
      $capsule-&gt;bootEloquent();
  </code></pre>