Using homestead after the latest larabook lesson, when I run codecept I get this error
PHP Error: Maximum function nesting level of '100' reached, aborting
To fix it I edited /etc/php5/fpm/conf.d/20-xdebug.ini and added the following line
xdebug.max_nesting_level = 200
Was that the correct thing to do? It fixes the problem but always seems odd to me to need to edit an ini file for such a simple application. I find it odd because we don't always have access in a production env to edit ini files but since this is only happening during testing I have complete control so I only question what exactly causes this. Is it a bug? Or just something that happens in testing?
This is usually caused by circular dependency, and it's incredibly hard to debug. Here's an example of what I'm talking about.
class ClassOne {
public function __construct(ClassTwo $classTwo)
{
$this->classTwo = $classTwo;
}
public function test()
{
return $this->classTwo->test();
}
}
class ClassTwo {
public function __construct(ClassOne $classOne)
{
$this->classOne = $classOne;
}
public function test()
{
return $this->classOne->test();
}
}
$circular = new ClassOne;
return $circular->test();
I've seen something about this on the old forum, quoting one of the posts by bacondrinker:
"I have thought about dong that, but I would consider that a last resort, I am certain this is an underlying problem and I think raising the xdebug max function nesting value would be ignoring the issue. If I ignore it I am sure it will come back to bite me in the ass."
Thanks for the replies. The strange thing is I test several times before and after changing anything and did not have this issue until the latest lesson adding the mailer and handler for the UserHasRegistered event but we didn't write any new tests. The only thing I can think of that would be related would be the test for registering a new user but it doesn't test the event or handler.
I've never really used xdebug so not sure how it works but I'm guessing when the test for registering a user runs xdebug is loading even classes not under test. I'll look through the new code and see if I can see anything causing a circular dependency.
Well, I can't find any circular dependencies. I think I understand why xdebug is throwing the error though. With xdebug enabled even though I'm not testing the mailer or event handler, xdebug is loading and checking every file that is touched when the test is run. I ran only the SignUpCept and the issue is definitely coming from the $I->click('Sign Up') when the signup process triggers the UserRegistered event and Laravel's listener tries to handle it.
If anyone wants to look at the long output stacktrace and see if you see my issue, here it is http://laravel.io/bin/110nP
Looks to me like Swift_DependencyContainer tries multiple times to resolve dependencies so maybe that has to do with the problem?
I am having the exact same issue, but with Laravel 5 running under Homestead. I have an event that is triggered, and a queued event handler that then sends a queued email. Glad to know I’m not going insane and that this is an issue.
I have the same issue running Laravel 5 and Homestead.
I am using a custom made viewbuilder, which generates some amount of nesting.
I figured PHPUnit is using 12 nesting levels alone when viewing the output of the Exception, so I increased the max level of nesting to 112. This helped, but I know I'm walking on the limit!
@martinbean my problem is the same, i.e. "with Laravel 5 running under Homestead I have an event that is triggered, and a queued event handler that then sends a queued email".
Setting xdebug.max_nesting_level = 200 solves the problem but well... didn't expect to have more than 100 nesting levels.. it's weird
I've been there while migrating my L4 service to L5. I've been using Mail facade in my custom send method, and on each concrete mail method (e.g. welcomeUser) I utilized that custom send. I met the xdebug error message whenever the application hit the SwiftMailer.
My solution was so simple: swapping the Facade to Illuminate\Mail\Mailer. app('Illuminate\Mail\Mailer')->send() instead of Mail::send(). Hope that helps.
It all works fine for me on Homestead but I get the PHP Error: Maximum function nesting level of '100' reached, aborting when on Digital Ocean server (via forge). Do I edit xdebug.ini on DO just the same? Do I need to do anything extra? Thanks