redbonzai
2 years ago
6995
4
Laravel

Solution for: Maximum function nesting level of '512' reached, aborting! Error

Posted 2 years ago by redbonzai

Currently, I am needing to test some model relations so in my model I load its relations using the $with array like so:

protected $with = [
        'user', 'activities', 'defaultMetric', 'metricTemplates', 'valuesPerSet'
    ];

That caused the following debug error:

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Maximum function nesting level of '512' reached, aborting!

Here is the fix:

If you are using Laravel Homestead, go into your xdebug.ini file under your PHP version like so:

sudo nano /etc/php/7.2/mods-available/xdebug.ini

The xdebug.ini file looks like this for me:

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

Change 512 to 1024 ( or a larger number, whatever your memory can afford ).

Then restart nginx and php fpm.

sudo service nginx restart
sudo service php7.2-fpm restart

Voila!

I hope this helps you. I spend too long figuring this out.

Christian

Please sign in or create an account to participate in this conversation.