Open JrIndie opened 6 years ago
Where do you have that all set?
Inside a custom component that gets bootstrapped right after log,
frontend/config/main.php
'bootstrap' => ['log', 'ConfigSettings'],
That'll probably be too late within the code.
The basic and advanced templates set the YII_DEBUG
and YII_ENV
constants in the web/index.php
file so by the time your config file is loaded they're already defined.
You'll need to put them in the index.php
file.
Okay, testing it now. Is the web/index.php called every page? Is there any other such files? I was hoping to call my component before everything else to be able to set up configurations for production/dev modes.
Tested, seems like I get a white page now. :-(
The index.php
will be your entry point from the web that sets up the application.
Yii2 has environments
where you can have configs for dev and production which can be switched using the init
command.
https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/structure-environments.md
Okay thank you. However, I get a white page now ... Is there anything wrong with my settings? ><
Did it work before?
Yes, indeed, sorry if I did not say so before.
It seems like its halting loading the page. ><
Thank you for your question. In order for this issue tracker to be effective, it should only contain bug reports and feature requests.
We advise you to use our community driven resources:
If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.
This is an automated comment, triggered by adding the label question
.
@Alex-Code @samdark
Huh? Can you please advise me? I spent the last year and a half developing using this software, and my settings are correct, but it just shows a white page when in prod, and when I use dev mode it will show the error log. Obviously because I am doing an error on purpose so I can test to make sure it just ignores it. If there is no error(I do it on purpose), my site is working or else I would not have been posting here.
Seems like the following is what is happening: http://www.yiiframework.com/forum/index.php/topic/22583-yii-debug-false-shows-php-notice-errors-and-stops/
How to reproduce:
Step 1: Change to Prod Mode with the following settings on the web/index.php Step 2: On another page do the following:
<?php
ThisFunctionDoesNotExistWeShouldIgnoreThisError();
?>
Why disabling all the error handling?
Because in the event of a bug or some poor coding by someone(we all make mistakes) I dont want anyone to see the stack trace, or any important information. Especially due to those script kiddies and php injection tricks to cause errors. It would be impossible for me to prevent all of them, I try and probe my own site, but I am not the best, and the last resort is to just log it on the server but dont show anything.
defined('YII_DEBUG') or define('YII_DEBUG', false);
should be enough for the purpose.
Yes, and I am doing that, but it is just causing the page to be white and not respond (halting most likely). I am inside a big project, so we have a lot of moving parts. Maybe I will just start a new project and do my test to make sure its working as intended and report back.
Thank you for your time. You have an amazing product!
@samdark Sorry to bother you again. Can you just let me know something before I head off? I think I know why it doesnt work. I was thinking Yii would be able to determine if a function does not exist and inspect it before it is called, and be able to handle it for me. This does not seem to be the case, and I have been testing and doing this for days!
So it does infact IGNORE the error, but it just kind of lets php hang! ^_^
I have tested various type of errors, but all of them cause the page to halt (white). There are 13 total errors in PHP and I dont know how I can test all the other ones.
This was with your settings enabled: defined('YII_DEBUG') or define('YII_DEBUG', false);
And having the following code on another page, one at a time to test.
Fatal Error(); // Halts Page
ParseError() // Halts Page
include('WarningError'); // Shows Page
echo $NoticeError; // Shows Page
So, it appears to me, that yii will show the page depending on the error.
Final Question: Is there any errors in php that yii will find, and ignore and gracefully act as if nothing has happened, besides the above two?
Thank you so much!
EDITED Corrected include('WarningError'), and echo $NoticeError;
Final Question: Is there any errors in php that yii will find, and ignore and gracefully act as if nothing has happened, besides the above two?
No. The two above should be handled as well if you're not turning off error handlers.
Would you please provide steps to reproduce the issue starting with basic application template?
@JrIndie have a look at PHP's error log if you are getting a white page.
I have the following set:
error_reporting(E_ALL & ~E_NOTICE); ini_set('display_errors', 0); ini_set('log_errors', 1); defined('YII_DEBUG') or define('YII_DEBUG', false); defined('YII_ENV') or define('YII_ENV', 'prod'); defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', false); defined('YII_ENABLE_EXCEPTION_HANDLER') or define('YII_ENABLE_EXCEPTION_HANDLER', false);
Using Apache2, and yii2.
However, when I purposely try and cause an error by calling some unknown function, ill get the usual stack trace that I get inside dev mode.