Controlling the PHP error level in a WAMP virtual host

I usually set error_reporting to E_ALL when developing (forces you into good coding habits). When upgrading to PHP 5.3, a lot of “Deprecated” messages started showing up in some external software, though (things like CakePHP, WordPress, and Joomla). Since I’m not about to touch that stuff, it’s far easier to simply lower the error reporting level in the short run.

Using the php_admin_flag, this is easy, once you translate the PHP constants into integers. In the virtual host configuration (located in conf/extras/httpd-vhosts.conf in the latest version of WampServer), just add something like this:

  1. ...
  2.  
  3. Listen XX
  4. <VirtualHost *:XX>
  5. DocumentRoot "C:/path/to/root"
  6. <Directory />
  7.  ...
  8.  
  9.  <IfModule mod_php5.c>
  10.  php_admin_flag engine on
  11.  
  12.  # choose the one you want:
  13.  
  14.  # This is for E_ALL & ~E_STRICT & ~E_DEPRECATED
  15.  # php_admin_value error_reporting 22527   
  16.  
  17.  # This is for E_ERROR
  18.  # php_admin_value error_reporting 1   
  19.  
  20.  </IfModule>
  21.  
  22. </Directory>
  23. </VirtualHost>
  24.  
  25. ...

Enjoy.

Leave a comment

Your email address will not be published. Required fields are marked *