Jan Pech
Jan Pech

Reputation: 75

Symfony 4.0 in "prod" mode doesn't throw exception when key in array does not exist

I've made application in Symfony 4.0. When I try to access key in array, which does not exist, in "dev" mode, PHP throws exception as you would expect. But when I switch to "prod" mode, it starts to act strangely.

"dev" mode:

$var = $array["key_which_does_not_exist"];
//this throws exception

"prod" mode:

$var = $array["key_which_does_not_exist"]["another_key_which_does_not_exist"][0]
//in $var is null

Upvotes: 0

Views: 585

Answers (1)

Fabien Papet
Fabien Papet

Reputation: 2319

This is expected as symfony prod environnement has debugging set to false by default.

In fact, this is PHP's behaviour that is overriden by Symfony. You can override how PHP handles your errors.

http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

Symfony uses this feature to override this behaviour whether if you have debugging activated or not. It is not in prod environment, and it is in dev as you can easily spot your errors

Upvotes: 2

Related Questions