PHP on OpenShift: How to enable errors and warnings? - php

I have moved my app to OpenShift and now, for convenience of getting it actually work, I'd like to enable in-page errors and warnings. Currently, I see a blank page.
How can I enable errors?
In PHP, it's in php.ini
error_reporting = E_ALL
display_errors = 1

On the IRC channel #openshift, I was told that this is not currently not configurable
(05:06:58 PM) pmorie: ozizka-ntb: it looks like it's provided by the cart - i don't believe you can substitute your own
and I need to use both
error_reporting(E_ALL);
ini_set('display_errors', 1);

You might want to set APPLICATION_ENV to development.
$ rhc env set APPLICATION_ENV=development
According to https://developers.openshift.com/en/php-getting-started.html,
In development mode, your application will:
Show more detailed errors in browser
Display startup errors
Enable the Xdebug PECL extension
Enable APC stat check
Ignore your composer.lock file (if applicable)

If you can't access php.ini then write this on top of your php page:
<?php
error_reporting(22527);
?>
This displays all errors and warnings in the page.

Related

Can't disable error reporting in OpenCart (PHP)

I can't seem to disable error reporting in PHP - I have tried everything but "Notice" errors are still displayed.
My php.ini has
display_errors = Off;
error_reporting = 0;
My .htaccess has
php_value error_reporting 0
And my script has
ini_set('display_errors', 'Off');
ini_set('log_errors', 1);
ini_set('error_reporting', 0);
ini_set('display_startup_errors', 'Off');
php_info();
echo $my_undefined_var;
The php_info() output confirms that display_errors and error_reporting are indeed off and 0, and yet I still get a notice,
Notice: Undefined variable: my_undefined_var in /my/site/path/index.php?blahblah...
Note this is an OpenCart website (and my change is in the Admin section). I have tried creating a test php script in the same directory as index.php and it's fine.
Is there anything else that could be overriding the error_reporting(0) ?
I've done a grep of the entire site to find and disable all mentions of the error_reporting and display_errors but to no avail.
There is a setting within the OpenCart dashboard that allows you to turn on (or off) error reporting and logging.
Log into your dashboard
In the menu, go to "System" and select "Settings"
In the list of stores, click "Edit" for your store
Click the "Server" tab.
Scroll down, and there's two settings:
a. Log Errors - set this as desired
b. Display Errors - set this to "No"
As #colmde already pointed OpenCart uses custom error_handler.
You can turn error displaying off without any code edits (especially OpenCart core files) via:
Admin->System->Settings->[edit your configured store]->Server->Display Errors
[EDIT]
You can do the same by running following query against OpenCart database:
update setting set `value`= 1 where `key` = 'config_error_display'
OpenCart uses the set_error_handler() function which causes it to override the error_reporting(0).
Removing this fixed my problem.
you can simply use
ini_set('display_errors', 0);
on system/startup.php
True way in OpenCart.
$this->config->set('config_error_display', 0);
$this->processAction(); // it throws ugly warning
I've tested in the controller of my module.
Just to turn off showing errors before your code.
It affects only current session (perhaps even current page).
It doesn't affect the DB!
for me helped:
//error_reporting(E_ALL);
in file startup.php

PHP errors make page inaccessible

Every time I have an error within my code and try to run it, the page becomes inaccessible. This is clearly very frustrating as it's hard debugging code with no feedback.
Relevant information from cPanel:
Apache version 2.2.22
PHP version 5.3.14
MySQL version 5.1.68-cll
Architecture x86_64
Operating system linux
If more information is required then please ask, I'm sorry I cannot provide any more information but frankly I am stumped.
Thanks.
Enable error reporting to see what error PHP had, if it had one.
There are several places you can look, firstly try checking your Apache error log. In many cases this is located in /var/log/apache2/error.log . Another way to debug a page like this is to enable error logging.
The simplest way of doing this being adding these lines to your php file:
ini_set('display_errors',1);
error_reporting(E_ALL);
In addition to this, you can also clean up the errors formatting by adding:
ini_set('html_errors', 'On');
In addition to this method of enabling error reporting, you may also enable them from you configuration file by adding the following line:
error_reporting = E_ALL
You need to update your php.ini to display errors. There are a couple settings.
Search your php.ini for display_errors and error_reporting. The file is usually commented very well on the options for error reporting, but error_reporting = E_ALL is a typical setting. Sometimes people want to suppress notices and set error_reporting to E_ALL & ~E_NOTICE.
display_errors = On is the config to print the errors to the screen.
After changing your php.ini, Apache usually needs to be restarted. I'm not sure how much control you have over your server, so if you can't restart Apache but you have a php.ini available, your host probably has it configured so you don't need to restart.

MAMP pro PHP Error handling grief

So mamp pro is all set up using PHP 5.3.6 / cache is XCache, error handling set to Display Startup errors - write to All errors and warnings - to set to Display and Log both checked.
restart the server, intentionally wrote some code that should bring up an error..
<?php
echo stupid;
?>
Yes this is all thats in the code.
I get nothing! No errors, only in the log.
I don't want to have my console open the entire time watching for errors, I want them printed on the screen.
The only way I can get this to work is by doing an INCLUDE on this code at the top of EVERY SINGLE PHP file.
error_reporting(E_ALL);
init-- yad yada ('display_errors', 'on');
From what I'm reading elsewhere, it seems like this is a big problem..
So how can I set up my mamp pro PHP.INI file to work properly and print directly to my browser?
I changed it in MAMP/bin/php/php5.3.6/conf/php.ini
You can change display_errors and display_startup_errors

Enable errors in browser when parsing PHP-files

I recently changed to a MacBook and now use the MAMP-stack for development locally.
In my earlier development environment I always could see informative error-reports when I tried to access a PHP file through a web-browser and an error occurred. With the default installation of MAMP it seems that this feature is disabled, whenever I hit an error I can't see the cause of it, I can't even see a single line informing me that an error occurred.
Not until I start to debug the code in a debugger I can see where the error occurred.
Any idea how error reporting can be turned on?
I tried:
error_reporting(E_ALL);
No effect at all though.
reporting level to E_ALL and display errors on Include the following code at the top of every php file on in an include or require such as your config.php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
Try ini_set('display_errors', 'on');
You'll also want to check a phpinfo(), to see if the ini_sets are doing anything.
Or change "display_errors = Off" to "display_errors = On" in /Applications/MAMP/bin/php/php5.4.4/conf/php.ini
Navigate to MAMP settings (eg localhost:8889/MAMP)
Click PHP Tab
Find Log errors: setting
Tick to screen
Click Save

php project deployment problem

i have done onw project in php. It works on my windows pc. I use xampp on my windows machine.But when i devlopy same on my linux machine it shows me some blank pages.
Some pages are completely blank.some are half blank.
whats the problem?
Those blank pages could be because there is an error that is not displayed -- will be hard to guess what, though, so here are a couple of pointers :
Did you check if there is anything useful in your Apache's log files (something like /var/log/apache/error.log, or close to that, generally).
You can also enable display_errors and/or configure error_reporting, to get more informations -- or have them displayed on screen, which might be a bit easier, as long as you are developping and your application is not deployed to the production server.
This can be done in the php.ini file, if you can modify it, with something like this :
error_reporting = E_ALL | E_STRICT
display_errors = On
html_errors = On
Or it can also be done directly in your code, at the beginning of it, with something like this :
error_reporting(E_ALL);
ini_set('display_errors', 'On');
To enable error_reporting for all kinf of errors, and display those errors.
You might also want to install Xdebug on your development box, to get nice stacktraces when an error / exception occurs -- just don't install it on a production server !
Of course, on your production machine, you probably don't want to display errors ; so that will have to be configured depending on your environment ;-)

Categories