Edit: json_decode returns NULL for an empty input string (in recent PHP 7.4). Are you correctly handling NULL values, e.g. when iterating over it in a loop in the template?
Is this a staging/production server? It may be a good idea to show a proper server error page to the visitor instead just an empty HTTP 500 header response.
the funny part is that the result is a json from any of those, ok?
if I call json_decode, it crashes, on localhost, nginx…not in production with apache
But this is the nginx error. Isn’t there a PHP log, too? upstream is the PHP FastCGI daemon which response nginx passes through.
In this case PHP encountered an error and didn’t give nginx the expected response.
The error can be anywhere here, from some unexpected JSON input string to non-existing variable in a template.
In any way there is a PHP daemon on your development system that got its own log.
You need to get the log from it to find the exact reason.
This is also the only proper way doing development/debugging. Everything else would be just guessing.
When you can find the httpd/apache logfiles under /var/log/httpd or similar, the php-fpm log files should be found under a similar directory, e.g. /var/log/php-fpm or maybe /var/log/php (without the -fpm).
Edit: Also try out the locate command for a quick-and-dirty system-wide search for these files.