How can I turn on PHP errors display on just a subfolder

php

Solution

In `.htaccess`:

php_value error_reporting 2147483647

This number, according to documentation should enable 'all' errors irrespective of version, if you want a more granular setting, manually OR the values together, or run

php -r 'echo E_ALL | E_STRICT ;'

to let php compute the value for you.

You need

AllowOverride All

in apaches master configuration to enable .htaccess files.

More Reading on this can be found here:

- Php/Error Reporting Flag

- Php/Error Reporting values

- Php/Different Ways of Tuning Settings

Notice If you are using Php-CGI instead of mod_php, this may not work as advertised, and all you will get is an internal server error, and you will be left without much option other than enabling it either site-wide on a per-script basis with

error_reporting( E_ALL | E_STRICT ); 

or similar constructs before the error occurs.

My advice is to disable displaying errors to the user, and utilize heavily php's error_log feature.

display_errors = 0
error_logging = E_ALL | E_STRICT 
error_log = /var/log/php 

If you have problems with this being too noisy, this is not a sign you need to just take error reporting off selectively, this is a sign somebody should fix the code.

@Roger

Yes, you can use it in a `<``Directory>` construct in apaches configuration too, however, the .htaccess in this case is equivalent, and makes it more portable especially if you have multiple working checkout copies of the same codebase and you want to distribute this change to all of them.

If you have multiple virtual hosts, you'll want the construct in the respective virtual hosts definition, otherwise, yes

  <Directory /path/to/wherever/on/filesystem> 
      <IfModule mod_php5.c>
         php_value error_reporting 214748364
      </IfModule>
  </Directory>

The Additional "ifmodule" commands are just a safety net so the above problem with apache dying if you don't have mod_php won't occur.

Problem

I don't want `PHP` errors to display /html, but I want them to display in `/html/beta/usercomponent`. Everything is set up so that errors do not display at all. How can I get errors to just show up in that one folder (and its subfolders)?

Original source