1

I am running a website on Laravel and it was working fine on local system as well as on server previously.

Suddenly, this website has stopped and not working for few pages. On debugging or checking error log, I have found an error related to "Maximum function nesting level reached".

To find out for what thing, I am getting this error, i have debugged the code and found the below lines for which I am getting this error:

$customer = \App\Models\Customers\Customer::find(123);  
echo $customer->toJson();  //Getting error for this line  

Also tried to use toArray() instead of toJson(), but getting same error.

Now, I am not able to understand, why I am getting nesting level issue for just fetching only 1 record from database. Even customer table has few columns with not so much big data.

Can someone please help me? what is the reason behind the same?

Dhirender
  • 604
  • 8
  • 23
  • 1
    Possible duplicate of [Solution for "Fatal error: Maximum function nesting level of '100' reached, aborting!" in PHP](https://stackoverflow.com/questions/8656089/solution-for-fatal-error-maximum-function-nesting-level-of-100-reached-abor) – sh1hab Oct 22 '19 at 06:20

1 Answers1

1

Maybe it is a Webserver configuration for xdebug you can increase it with

max_nesting_level

in your xdebug.ini or whereever you configurates your xdebug

bomel2k9
  • 141
  • 3
  • Thanks for reply. When I increase the same then I am getting "This site can't be reached" error. And in error log there is no log for the same. and one more thing, I am just trying to fetch single record and there is no loop then why laravel is suddenly throwing this kind of error. And on my system, there is no xdebug installed. Please help me. – Dhirender Oct 23 '19 at 02:18
  • Have you checked for back Relations or Relations to other Models which cause this error? Maybe this one : https://stackoverflow.com/questions/36579389/laravel-5-2-maximum-function-nesting-level?rq=1 can Help you, too :) – bomel2k9 Oct 23 '19 at 08:53