2

I have the issue that laravel (version 8) adds php notices I get to the response as html string. This is really annoying because the response should be json and now I have string that contains html and json. This is how the response looks:

<br />\n<b>Notice</b>:  Unknown: file created in the system's temporary directory in <b>Unknown</b>   on line <b>0</b><br />
{\"type\":[\"The type field is required.\"]}

Any idea how to disable this behaviour ?

I already tried using phps error_reporting() function. Even with APP_DEBUG=false this occurs.

Silex
  • 31
  • 3
  • 1
    Does this answer your question? [Notice: Unknown: file created in the system's temporary directory in Unknown on line 0](https://stackoverflow.com/questions/48192705/notice-unknown-file-created-in-the-systems-temporary-directory-in-unknown-on) – Andrea Olivato Jun 13 '21 at 06:23
  • No, unfortunately it doesnt. My issue isnt that the warning is occuring but that laravel is sending it back with the response content ;-; – Silex Jun 30 '21 at 13:15
  • Did you solve it? Im with the same issue – Juan MP Feb 21 '23 at 14:04

1 Answers1

0

I just hit this too, I fixed it by setting the php display_errors runtime config value to off. See https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors


More specifically, on my macos/Brew PHP setup it was by editing

/usr/local/etc/php/8.0/php-fpm.d/www.conf

and removing the commenting-semicolon on this line

;php_flag[display_errors] = off

and restarting the php@8.0 service

brew services restart php@8.0

On other platforms like Ubuntu, it might be found by grepping under /etc/php for display_errors

barryp
  • 126
  • 3