简体   繁体   中英

PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in Laravel

I had this error twice and spent almost 30 minutes to debug it each time. I Hope it will help somebody because all I've found on the internet is solution for turning off xDebug.

PHP Fatal error: Maximum function nesting level of '100' reached, aborting!

This happened to me because I have accidentally injected two classes into each other.

class Foo(Bar $bar){}

class Bar(Foo $foo){}


$bar = new Bar(new Foo(new bar(new Foo(...))));

The reason why didn't saw that is because of Laravel IOC. So synax for instantiating a class would be something like:

$bar = new Bar(Foo $foo);

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

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));

This answered helped me.

https://stackoverflow.com/a/30839127/3524046

Here the issue in my case.

I have a service class which is librarie in codeigniter. Having aa function inside like this.

class PaymentService {

    private $CI;

    public function __construct() {

        $this->CI =& get_instance();

    }

    public function procss(){
        // lots of Ci referencing here ...
    }

my controller as followed:

$this->load->library('PaymentService');
$this->process_(); // see I got his wrong instead it should be like below

$this->Payment_service->process(); //the library class name

Then I was keeping getting the exceed error message. But I do disable XDebug but non helped. Any way please check you class name or your code for proper function calling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM