15

I'm getting this error message in my Laravel application after I upgraded to Laravel 5.1.

FatalErrorException in Dispatcher.php line 200:
Maximum function nesting level of '100' reached, aborting!

enter image description here

This issue occurs on some URLs of my app. I have done dozens of composer update but issue still persist. Any suggestion at all will be appreciated

Emeka Mbah
  • 16,745
  • 10
  • 77
  • 96
  • You can increase the limit in php.ini, but this is likely a logic error - some function is either calling itself or a loop isn't being properly closed. – versalle88 Jun 12 '15 at 13:24
  • Thanks, Yes I think a function is calling itself over and over. I don't wish to increase limit in php.ini, will like to find and fix it – Emeka Mbah Jun 12 '15 at 13:55

3 Answers3

49

Issue is caused by default xdebug.max_nesting_level which is 100.

The workaround for now is to increase xdebug.max_nesting_level to a certain level say 200 or 300 or 400

I fixed mine by increasing xdebug.max_nesting_level to 120, by adding the line below to bootstrap/autoload.php in Laravel 5.1

ini_set('xdebug.max_nesting_level', 120);

.........

define('LARAVEL_START', microtime(true));

Emeka Mbah
  • 16,745
  • 10
  • 77
  • 96
10

The problem is created because of 1 PHP extension in Apache- php_xdebug

So, the solution is-

  1. Disable the extension
  2. Increase the nesting level of the extension
  3. Increasing max_nesting_level in laravel

In detail

Option 1-

To disable it, you can follow this.

If you are using WAMP Server, then you can easily do it by going to php.ini- enter image description here

And then commit this-

zend_extension = "c:/WAMP/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll"
  • Path should be different from PC to PC
  • Adding an # before the line is a comment

Option 2-

You can increase the limit by this way.

If you are using WAMP Server, then you can easily do it by going to php.ini-

And after zend_extension = "c:/WAMP/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll", there should be something like this-

[xdebug]
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/WAMP/tmp"
xdebug.show_local_vars=0

Then, just add 1 line there-

xdebug.max_nesting_level=500

Option 3-

You can also set this configuration in Laravel autoload.php file.

You can simply add this line in the file (anywhere in the file)-

ini_set('xdebug.max_nesting_level', 500);

And you will be done :)

Community
  • 1
  • 1
Abrar Jahin
  • 13,970
  • 24
  • 112
  • 161
0

This issue is due to xdebug extension is enabled, to fix this either you have to disable xdebug extension or edit php.ini file and change xdebug.max_nesting_level to 200 ( as by default this parameter is not included in php.ini and have to add it )

like :

xdebug.max_nesting_level=200

Naveed Asim
  • 109
  • 4