1

codeigniter has in index.php define('ENVIRONMENT', 'production'); for whole website. I am makeing changes in specific controller so I would like to have setting define('ENVIRONMENT', 'development'); for this controller but leave 'production' for all other controllers.

Is it possible to achieve this?

peter
  • 4,289
  • 12
  • 44
  • 67

1 Answers1

2

This constant is set just for enabling disabling errors. The production ENVIRONMENT disables all errors. If you want to enable development for a specific controller, then just place the below code at top of that controller.

error_reporting(E_ALL);

OR

ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);

Also read

How do I enable error reporting in PHP?

Community
  • 1
  • 1
Altaf Hussain
  • 5,166
  • 4
  • 30
  • 47
  • thanks. But when I insert this in controller at the top and then I make some error in that file (for example I forget to finish variable with ;) and then refresh page, my page won't show me error. Any idea how to treat this? in short - I need to show all errors and warnings for particular controller/view/model which is under development. – peter Nov 17 '13 at 18:20
  • Updated my answer. Try it. – Altaf Hussain Nov 18 '13 at 07:07
  • Hello, thanks for your update and your effort. Please see below - I think it is not possible to set it in file (if fatal errors are in this file as well). I checked your link where Marc B wrote: Turning on error reporting from within a script is useless, as it won't help with syntax errors or other fatal errors that kill the compile phase. The script gets killed long before it begins executing and reaches the reporting overrides. – peter Nov 18 '13 at 15:45
  • Kindly look into these links: http://www.phoca.cz/documents/16-joomla/336-how-to-enable-displaying-php-errors-on-site , http://us1.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting and http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php . Hope this will help you. – Altaf Hussain Nov 19 '13 at 05:35