I've been using Zend Framework and just living with this problem for a while, but it's now just gotten too annoying so i'll send the question out to you.
There are certain problems within the Zend framework that Zend can recognize (such as calling a nonexistent controller), and will send that problem to the ErrorController. I've got that working fine.
There seem to be some problems that Zend Framework will fail and display the error through php, like if a certain function doesn't exist or something. Those I can see and fix.
Sometimes though, Zend won't fail, but it will also just send out an empty response. I will get a blank page. They layout doesn't show up, there's no code, there's no nothing to give me an idea of what's gone wrong. Last time, there was a require() that failed. I had to manually figure this out with no feedback.
Have any of you experienced this? Do you have any advice on how to get these errors to show? Any help would be appreciated!
The internal error handling of the framework's MVC components can only trap Exceptions, not PHP errors.
To assist in debugging during development, you can use the standard:
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'on');
Also, if you're using the new Autoloader included with 1.8, use:
Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(false);
To allow failed include/require statements to be issued.
For others coming across this question: I changed the following line in configs/application.ini
resources.frontController.params.displayExceptions = 0
To:
resources.frontController.params.displayExceptions = 1
This allowed me to see the full Exception, including stacktrace.
Set this in your config:
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
Edit the file public/index.php.
Change the APPLICATION_ENV to 'development'.
This will use the development settings in your application/configs/application.ini file. Those settings define whether to suppress errors.
It's too late to answer this question now. But hope it will help someone else...
Just place the following function in your Bootstrap.php file to enable exceptions..
protected function _initErrorDisplay(){
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
}
Open urproject/application/config and open application.ini
Change the second line:
phpSettings.display_errors = 0
to
phpSettings.display_errors = 1
Now it will display errors.
Fast and dirty decision, if none of already mentioned methods worked (useful for old or ugly-configured version of ZF):
find ErrorController of your application.
put the call of debug_print_backtrace function at the top of init method (with die() optionally)
For anybody for whom the answers given here didn't work, one can always go to the apache logs to see a description of the problem. It would of course be more convenient if this showed on the page, but I find it to be an acceptable alternative.
/var/log/apache2/error.log
I have this file open with vim and type :e to refresh and G to go to the bottom of the page to see the most recent error when I get the blank page. It tells you the time the error occurred, the message and the line, so it's pretty helpful.
put these lines in application/configs/config.php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'on');
Related
I'm developing with Symfony 2. The thing is that not always I can see the errors or var_dumps that I use to debug. I can see them if I go to inspector->network and select the proper file and this is very annoying.
How could I see it directly to the browser?
I use Xdebug.
I have in my php.ini:
display_errors = On
And I tried with:
xdebug.force_display_errors = 1;
xdebug.force_error_reporting = -1;
but that doesn't work.
Any idea?
------- Editing ------
This is an example of how i have to debug.
I have to go to inspector -> network and select the proper file. Apart of being very annoying, it is not efficient. Problem to see the full result as I cant scroll down or scroll right.
----- End Editing -----
I'd like to avoid to write any init_set or others options in my code if possible.
Another question... if a var_dump have more than 120k character or it is protected property how can I display it? So far I was changing it to public to dig in.
You have 2 ways to resolve your issue. First - you can directly use under your class namespace ini_set('error_reporting', E_ALL);, (but this is a not a best practice) or try to find the same string in your php.ini file and set it to E_ALL
error_reporting = E_ALL
display_errors = On
And finally you need to restart your web server.
About your second question - use Symfony Var Dumper for nice data output. Note that var-dumper sometimes is not compatible with old symfony versions. Use var-dumper 3.4 for best compatibility.
I have a simple self-made MVC structure composed by Controllers, Models and Views.
It was working fine, but now one controller is performing very strange behaviour...
Script gives error 500 (if you check headers) but execution and output is ok.
No error messages, no error log, nothing... but let me tell you the most strangest thing:
if I write debug directives for log information like these
error_reporting(E_ALL);
ini_set('display_errors', 1);
Then error 500 disapears... instead of displaying error information, and work like a charm.
Can't understand this situation. Any help?
Regards
Problem solved. I was using a PHP include which contain some # symbols, for example: #file_get_contents... This is a not recommended practice, now I know why :)
Thanks for your interest
I have a staging server running a Yii application that now gives a 'white screen of death'. I cannot see anything being ouputted to the screen (or even the source code when 'view source'), locally the same code runs without any issues.
Can anyone suggest a good routine to debug 'white screen of death' within a Yii application?
Getting a blank screen in yii is mostly because error_reporting is off.
Put
error_reporting(-1);
ini_set('display_errors', true);
in index.php should get your output back.
Note that you can always look in application.log and apaches error.log for informations when you don't have some output.
This is for Yii2
I found the code was failing in vendor/yiisoft/yii2/BaseYii.php at method autoload($className). It was failing at execution:
include $classFile; (line 293)
The cause in my case was a function method name declared twice.
You might be interested to know that you can discover the cause (which Yii2 suppresses through its own error-handling) by preceding the command with Chris's recommended code above https://stackoverflow.com/a/25139283/3125602. If you introduce them too early in the code, they get overwritten by Yii2's error-handling settings.
It is quite a simple issue and happens either when a script reaches the PHP memory limit or during a plugin or theme conflict.
Solutions :
Increase the Memory Limit :
Since this is regarded as one of the cause, it is recommended that the PHP memory limit be increased. Edit your wp-config.php file via FTP adding the following line of code:
define( ‘WP_MEMORY_LIMIT’, ‘64’);
This increases your memory limit to 64M. You might need to contact your host before you do it as some host don’t allow it from your end.
Deactivate all your Plugins :
Connect to your site via FTP and rename the wp-content/plugins folder to plugins_old to deactivate all your plugins.
Here is a detailed answer to the infamous "White Screen of Death" problem. Thank me later :)
https://www.perceptionsystem.com/blog/wordpress-errors-solution/
I'd like to see any PHP errors that are occuring, ie the "Expected ; on line 5 of myfile.php" sort of thing. Unfortunately, I cannot seem to figure out how to see this information.
I've set E_ALL, display_errors ON, friendly error messages are turned off, IIS is set to pass-through on errors, what am I missing?
Syntax errors used to show up as stated above on any page; they no longer do. We moved the server to a localhost for development, and I guess didn't mimic exactly the server config. Now I'm stumped.
Tried on IE and Chrome, neither of which show the errors.
Errors are logged in PHP's log file, but I'd still like them to be displayed on the page; at least for now.
UPDATE:
Just tried adding ini_set('display_errors', 'on'); directly into the requested page, and it now works.. but why? Why does it need to be set locally? My PHP.ini file has this declared already.
To answer the first part of the question; to see the errors when using ajax: You can use the developer tools of your browser to see the exact response from the server.
In FireBug for Firefox for example, you go to the Net tab and there you see all ajax request popping up as they happen. Opening one of these requests will give you an overview with more tabs like Response and HTML.
Try using:
error_reporting (-1);
E_ALL isn't really "all" for php < 5.4.
Also, make sure 'display_errors' is set.
ini_set( 'display_errors', 1 );
Well, looks like this is half my own stupidity, half the cloudiness of automatic installations.
Turns out there were TWO php.ini files, and that IIS used the one located within the iis express directory on the main drive, instead of the regular PHP directory.
So to anybody else having this problem, I'm providing the full list of crap you have to wade through to get the errors as you would like:
1) Turn off the IIS default error pages
2) Disable 'friendly error messages'
3) Ensure you are using the CORRECT php.ini file, and change the parameters as needed. Specifically error_reporting and display_errors.
All of this is necessary before seeing all of the error messages you need right in the browser.
I am running windows 7 and I have a fresh install of Zend framework. On a new php file called 'search.php' I am trying to build a search application using Zend_Search_Lucene with the first line being:
<?php require_once "C:...\Zend\Search\Lucene.php";?>
What I see on the browser when I run this code is internal server error 500..I then discovered that I get this error whenever I try to run some of the files in Zend library by itself and this is what caused the error I mentioned..i.e ERROR 500 on localhost/Zend/Search/Lucene.php, localhost/Zend.../blabla.php..
Some of the files however, did not display this 500 server error when run on the browser. ie: localhost/Zend/ProgressBar.php shows an empty page, which is fine since I assume there are not any 'echo'es in the code. This is actually what I expected when I ran lucene.php on the browser...
Can somebody experienced let me know how this can happen? Why do I get internal server error instead of exception? How do I check if my search application that uses "Lucene.php" file runs properly regardless of this internal 500 server error? thanks.
Try to turn on error reporting:
on the fly
ini_set('display_errors', 1);
error_reporting(E_ALL);
in php.ini (probably different for php and cli)
error_reporting = E_ALL
display_errors = 1
For more information see:
http://php.net/manual/en/errorfunc.configuration.php
http://php.net/manual/en/function.error-reporting.php
I have finally solved the problem :) After looking at the error traces, the internal server error is because the code <?php require_once "C:...\Zend\Search\Lucene.php";?> tries to access a particular code inside "Lucene.php" that contains a relative path to the Zend library folder =require_once('Zend\Search\Document\...'); and the server does not know the path to the file. What needed to be fixed was actually my php.ini file, on the include_path i added ;C:\php5\pear;C:\Server\www\.....\ZendFramework\library..Now it shows empty page instead of internal server error.
+1 #Arend: The error reporting function is really useful! thanks
Zend's code relies on their autoloader. You get an error, since you don't initialize it, then in Zend_Search_Lucene it tries to instanciate a nonexistent class.
This should do the trick:
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
self::$zendLoaded = true;
As I cannot comment answers, I re-use Maerlyn's code :
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
self::$zendLoaded = true; cannot work as self is not defined her.
According to the ZF documentation, if your path is set correctly, these 2 lines should be enough.