How to get native php http 500 error pages in symfony2? - php

In Symfony2 I'm getting a custom twig error message when an error 500 is thrown:
Oops! An Error Occurred
The server returned a "500 Internal Server Error".
Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
I just want default php errors instead.
If possible, only in dev.
display_errors is on in php.ini and looking at phpinfo()
I tried to add the following lines to app/config/config.yml
services:
twig.exception_listener:
class: DateTime
#dummy to prevent twig from handling http error pages
The result is that I get a blank page instead of the php error page with error and lines for debugging.
Thanks,
Boris

That's because Symfony2 wraps the whole process from the Request to the Response. Native PHP errors occur when not caught by Symfony2.
And native PHP errors can't be thrown if it's not a native PHP error. You'd get a real 500 error code page only if Symfony2 core would fail in rendering the response.
I don't see any other explanations. You can find more information about the error process by flowing this link.
This links explains why you do have a blank page : 500 error code exception is thrown but Twig is not listening this event anymore (as you disabled it). So nothing happens.

Related

No error message is displayed, the server only returned a "500 Internal Server Error"

I have set up a new Symfony3 project locally, but when I'm getting something wrong in my code the error is not displayed, only
The server returned a "500 Internal Server Error"
Is any other setting is required to display the exact error message on page?
Try to call app_dev.php instead of app.php, so in your web browser enter the yourdomain.dev/app_dev.php instead of yourdomain.dev.
A 500 error could be caused earlier in the request lifecycle than your application code, so it may not be possible to report further information "on page" depending on what service is failing. Those services may have their own settings for further error reporting in the response body; however, logs are typically the best place to look for services outside of the application code.
Turning on error reporting for your application as well, which, as #miikes suggested, in a standard symfony app can be done by using /app_dev.php instead of /app.php, could potentially provide more information if the error is in your application code.
Read your server service logs (e.g. tail -f /var/log/nginx/error.log) because 500 can be triggered by error on each level of your architecture (low on the server side or high in the app).
If you have errors in the application, very helpful would be set debug=true to the AppKernel (so you can just launch your application via app_dev.php instead of default app.php).

`Internal server error` when I try to view my wordpress page, and the same when I open it in website directly

The site give an error like
The server encountered an internal error or misconfiguration and was
unable to complete your request. Please contact the server
administrator, webmaster#stepprep.madoodles.com and inform them of the
time the error occurred, and anything you might have done that may
have caused the error. More information about this error may be
available in the server error log. Additionally, a 500 Internal Server
Error error was encountered while trying to use an ErrorDocument to
handle the request.
Apache Server at stepprep.com Port 80
[stepprep is my site name]
It used to work perfectly a while ago and now it showed like this..
I can't even view my page after coding it in wordpress dashboard.
This error will come because of your code is not formated well. For example you forgot to close if condition parentheses, syntax error etc... Please check you code what you have written.

Getting Error on Php Internal Server Error

I am getting Error i tried to find but did not get why getting Error.While its working fine on my localhost but not working on live server.
http://wellnessvisit.com/vascular-new/assets/global/plugins/jquery-file-upload/server/php/
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster#wellnessvisit.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Normally production servers are configured to hide all error information.
You can add these two lines in your main php file to see if there's a way to get the error information (temporarily, be sure to delete them after you're done debugging):
error_reporting(E_ALL);
ini_set('display_errors', 'On');
You can also check if there's an error_log file in the same folder as your PHP script, many servers log the errors to a file.
If no luck, with the previous lines, it might be a syntax error so the parsing is not completed.

Server returns blank page and 200 OK

our server on certain POST requests is returning a blank page with status code 200.
There is no PHP error. Problem reamains even if I manualy clear $_POST array.
How you got any ideas?
Configutation:
nginx
symfony 2.3.20
PHP 5.4.33-1~dotdeb.1
W also have varnish but problem remains after varnish shutdown.
Error reporting in on with option E_ALL
Well, in symfony2 it's easy to return like:
return new Response(null, 200);
wich does exactly what you say it does. Are you sure you are returning content from symfony2?
Which version of symfony you are using? The scenario looks more like a php error caused by mismatched function parameter or non existent function call.
-Run your application with debug enabled in your app_dev.php.
- add E_RECOVERABLE_ERROR in ErrorHandler.php handleFatal() funtion where error type is checked. Generally a mismatched function parameter throws a php error of type E_RECOVERABLE_ERROR and is not handled properly on symfony.
Once this is done run your page again. Hopefully the error will throw up on your page.
Hope this helps
Answering to my own question.
Indeed it was a PHP error - memory limit exhousted. It turned out when I binded to php cgi process via strace. Nginx did not return 500 status code. It did not even view fatal errors and log them (despite error_reporting = On with E_ALL).
I don`t know why. I will ask another question about that.

When PHP Fatal error happens, Nginx reports HTTP Error 500 to browser

My server is setup with Nginx + PHP + FastCGI. Whenever PHP throws a Fatal error, it gets logged inside of nginx/error.log, but the server reports HTTP Error 500 back to the browser instead of displaying the PHP Fatal error to the browser as is desired and typical in other setups. I've been searching for how to resolve this and keep coming up short. Anyone have anything helpful about this? Much appreciated!
Found it!
As of PHP 5.2.4, the default is now to cause a 500 error, because the alternative is an empty page.
Other discussions suggest that this behavior can not be changed for the "PHP Fatal" error type, which don't flow through the normal error handler routines and can not be caught or stopped.
You probably have php_errors off (or the displaying of them) in your php loader script... Try checking your php.ini settings...

Categories