我有兩次這個錯誤,並花費了近30分鐘,每次調試它。我希望它能幫助某人,因爲我在互聯網上找到的所有解決方案都是關閉xDebug。PHP致命錯誤:達到'100'的最大功能嵌套級別,正在中止!在Laravel
PHP Fatal error: Maximum function nesting level of '100' reached, aborting!
我有兩次這個錯誤,並花費了近30分鐘,每次調試它。我希望它能幫助某人,因爲我在互聯網上找到的所有解決方案都是關閉xDebug。PHP致命錯誤:達到'100'的最大功能嵌套級別,正在中止!在Laravel
PHP Fatal error: Maximum function nesting level of '100' reached, aborting!
這發生在我身上,因爲我不小心注入了兩個類到對方。
class Foo(Bar $bar){}
class Bar(Foo $foo){}
$bar = new Bar(new Foo(new bar(new Foo(...))));
之所以沒有看到那是因爲Laravel國際奧委會。因此,實例化類的synax會是這樣的:
$bar = new Bar(Foo $foo);
這裏的問題在我的情況。
我有一個服務類是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,但沒有幫助。任何方式請檢查您的類名或您的代碼進行正確的函數調用。
問題是由默認xdebug.max_nesting_level是100
通過添加以下行來引導/ autoload.php在Laravel 5.1
ini_set('xdebug.max_nesting_level', 120);
.........
define('LARAVEL_START', microtime(true));
這個回答讓我引起的。
這聽起來更像是一個「我也是」的評論,而不是實際的問題答案。 – hakre 2015-04-02 06:17:54