【问题标题】:PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in LaravelPHP 致命错误:达到“100”的最大函数嵌套级别,正在中止!在拉拉维尔
【发布时间】:2014-12-01 14:04:11
【问题描述】:

我两次遇到这个错误,每次都花了将近 30 分钟来调试它。我希望它会对某人有所帮助,因为我在互联网上找到的只是关闭 xDebug 的解决方案。

PHP 致命错误:已达到“100”的最大函数嵌套级别,正在中止!

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    问题是由默认 xdebug.max_nesting_level 100 引起的。

    通过在 Laravel 5.1 中的 bootstrap/autoload.php 中添加以下行

    ini_set('xdebug.max_nesting_level', 120);
    
    .........
    
    define('LARAVEL_START', microtime(true));
    

    这个回答对我有帮助。

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

    【讨论】:

      【解决方案2】:

      这就是我的问题。

      我有一个服务类,它是 codeigniter 中的库。像这样在里面有一个函数。

      class PaymentService {
      
          private $CI;
      
          public function __construct() {
      
              $this->CI =& get_instance();
      
          }
      
          public function procss(){
              // lots of Ci referencing here ...
          }
      

      我的控制器如下:

      $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
      

      然后我不断收到超出错误消息。但我确实禁用了 XDebug 但没有帮助。无论如何,请检查您的类名或代码是否正确调用函数。

      【讨论】:

      • 这听起来更像是“我也是”的评论,而不是问题的实际答案。
      【解决方案3】:

      这发生在我身上,因为我不小心将两个类相互注入了。

      class Foo(Bar $bar){}
      
      class Bar(Foo $foo){}
      
      
      $bar = new Bar(new Foo(new bar(new Foo(...))));
      

      之所以没有看到,是因为 Laravel IOC。所以实例化一个类的语法类似于:

      $bar = new Bar(Foo $foo);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-01-30
        • 1970-01-01
        • 1970-01-01
        • 2012-01-29
        • 2012-04-26
        • 2013-07-23
        • 2013-07-03
        相关资源
        最近更新 更多