title: Why has Xdebug detected a possible infinite loop?
body: <p>I wanted to share my problem that I faced and I will comment out the answer that I found to help with this issue:
  I replaced jwt-auth with sanctum then after finishing setting up the existing project from another developer I faced this error :
  <code>Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames laravel sanctum</code></p>
  <p>I added this line of code in <code>bootstrap/autoload.php</code> :</p>
  <pre><code>ini_set('xdebug.max_nesting_level', 10000);
  </code></pre>
  <p>and it didn't work either and kept changing the stack depth value to any value I'm giving and stuck in an infinite loop in logs.</p>
  <hr />
  <p>The solution was as simple as possible which is :</p>
  <p>adding <code>accept : application\json</code> in the header because sanctum can not work without it</p>
  <p>but here is the thing, it did not solve it it just hide it as it got caught in the error handler, I'll update once I solve it.</p>
  <p><strong>Solution</strong> :</p>
  <p>I found a line of code called &quot;guard : api&quot; in sanctum.php, when I removed it it worked and got out of the loop.</p>