title: xdebug failing to go into the laravel app
body: <p>I'm a big fan of using xdebug with laravel (esp in <a href="https://vi.stackexchange.com/a/14161/14510">vim</a>). However recently something weird has been happening (Note: my xdebug works perfectly when I'm running it on unit tests with this command: </p>
  
  <blockquote>
    <p>php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 ./vendor/bin/phpunit </p>
  </blockquote>
  
  <ol>
  <li>I first put a breakpoint in a controller method for example</li>
  <li>I run the command on the browser that would trigger an http call that will call that controller method
  the breakpoint appears here: (project/path/serve.php)</li>
  </ol>
  
  <p>&lt;</p>
  
  <pre><code>&lt;?php &lt;------- breakpoint appears here
  
  /**
   * Laravel - A PHP Framework For Web Artisans
   *
   * @package  Laravel
   * @author   Taylor Otwell &lt;taylorotwell@gmail.com&gt;
   */
  
  $uri = urldecode(
      parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
  );
  
  // This file allows us to emulate Apache's "mod_rewrite" functionality from the
  // built-in PHP web server. This provides a convenient way to test a Laravel
  // application without having installed a "real" web server software here.
  if ($uri !== '/' &amp;&amp; file_exists(__DIR__.'/public'.$uri)) {
      return false;
  }
  
  require_once __DIR__.'/public/index.php';
  </code></pre>
  
  <p>if i type the command "get all context" i get this: </p>
  
  <pre><code>$uri                 = /* uninitialized */'';
  </code></pre>
  
  <p>stepping through goes to the if ($uri line, in which case the uri is properly shown in the contxt</p>
  
  <p>as i step through to past the end of that file, it immediately jumps here:</p>
  
  <pre><code>/**
   * Handle the PHP shutdown event.
   *
   * @return void
   */
  public function handleShutdown()
  {
      if (! is_null($error = error_get_last()) &amp;&amp; $this-&gt;isFatal($error['type'])) {
  </code></pre>
  
  <p>at </p>
  
  <pre><code>Illuminate\Foundation\Bootstrap\HandleExceptions-&gt;handleShutdown()
  </code></pre>
  
  <p>then it immediately goes to the <a href="https://github.com/jenssegers/laravel-raven" rel="nofollow noreferrer">raven</a> service provider: </p>
  
  <pre><code>/**
   * Register the service provider.
   */
  public function register()
  {
  
      ..
      // Register the fatal error handler.
      register_shutdown_function(function () {
          if (isset($this-&gt;app['Raven_Client'])) { &lt;---- comes here
              (new Raven_ErrorHandler($this-&gt;app['Raven_Client']))-&gt;registerShutdownFunction();
          }
      });
  </code></pre>
  
  <p>at </p>
  
  <pre><code>Jenssegers\Raven\RavenServiceProvider-&gt;Jenssegers\Raven\{closure}()
  </code></pre>
  
  <p>then here @ Raven_Client->onShutdown() /path/to/project/vendor/sentry/sentry/lib/Raven/Client.php:1388</p>
  
  <pre><code>public function onShutdown()
  {
      if (!defined('RAVEN_CLIENT_END_REACHED')) { &lt;--
          define('RAVEN_CLIENT_END_REACHED', true);
      }
      $this-&gt;sendUnsentErrors();
      if ($this-&gt;curl_method == 'async') {
          $this-&gt;_curl_handler-&gt;join();
      }
  }
  </code></pre>
  
  <p>then here @ Raven_ErrorHandler->handleFatalError() /path/to/project/vendor/sentry/sentry/lib/Raven/ErrorHandler.php:126</p>
  
  <pre><code>public function handleFatalError()
  {
      unset($this-&gt;reservedMemory); &lt;---
  
      if (null === $error = error_get_last()) {
          return;
      }
  
      if ($this-&gt;shouldCaptureFatalError($error['type'])) {
          $e = new ErrorException(
              @$error['message'], 0, @$error['type'],
              @$error['file'], @$error['line']
          );
          $this-&gt;handleException($e, true);
      }
  </code></pre>
  
  <p>then here @ Monolog\Handler\RotatingFileHandler->__destruct() /path/to/project/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php:169</p>
  
  <pre><code>public function __destruct()
  {
      try {
          $this-&gt;close();
      } catch (\Exception $e) {
          // do nothing
      } catch (\Throwable $e) {
          // do nothing
      }
  }
  </code></pre>
  
  <p>how do i stop this from happening?</p>
  
  <h1>update</h1>
  
  <p>i removed the raven service provider from my env by doing this:</p>
  
  <p>class AppServiceProvider extends ServiceProvider
  {</p>
  
  <pre><code>/**
   * Bootstrap any application services.
   *
   * @return void
   */
  public function boot()
  {
      $env = config('app.env');
  
      if (!$env === 'local' || !$env === 'testing') {
          $this-&gt;app-&gt;register(\Jenssegers\Raven\RavenServiceProvider::class);
          $this-&gt;app-&gt;alias('Raven', Jenssegers\Raven\Facades\Raven::class);
      }
  </code></pre>
  
  <p>but then now when I debug, it still goes here:</p>
  
  <pre><code>/**
   * Handle the PHP shutdown event.
   *
   * @return void
   */
  public function handleShutdown()
  {
      if (! is_null($error = error_get_last()) &amp;&amp; $this-&gt;isFatal($error['type'])) {
  </code></pre>
  
  <p>at </p>
  
  <pre><code>Illuminate\Foundation\Bootstrap\HandleExceptions-&gt;handleShutdown()
  </code></pre>
  
  <p>but it skips the raven stuff.. so this is really my problem. There is an error that's happening but i would like to debug <em>before</em> i reach that error.. </p>
  
  <h1>update 2</h1>
  
  <ul>
  <li>I noticed that breakpoints in the middleware works just fine, but then it proceeds to skip my controller</li>
  <li>If I make the request from postman (I switched to the login api for smoketesing), it works just fine, this is what my postman command looks like (converted to curl):</li>
  </ul>
  
  <p>></p>
  
  <pre><code>curl --request POST \
    --url 'http://127.0.0.1:8000/api/users/login' \
    --header 'Accept: application/x.toters.v1+json' \
    --header 'Content-Type: application/json' \
    --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
    --form 'email={{client_user_name}}' \
    --form 'password={{general_password}}'
  </code></pre>
  
  <p>in the other hand, this is the request from the browser that doens't work:</p>
  
  <pre><code>curl 'http://127.0.0.1:8000/api/users/login'
  -X OPTIONS 
  -H 'Access-Control-Request-Method: POST' 
  -H 'Origin: http://localhost:3000' 
  -H 'Accept-Encoding: gzip, deflate, br' 
  -H 'Accept-Language: en-US,en;q=0.9' 
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36' 
  -H 'Accept: */*' 
  -H 'Connection: keep-alive' 
  -H 'Access-Control-Request-Headers: content-type' --compressed
  </code></pre>