Overriding PHP Config
From Liway Wiki
Contents |
Introduction
The PHP configuration is set centrally by Liway in a file called php.ini, however sometimes it may be useful to override certain directives for your own purposes. Not all PHP configuration directives can be overridden for security reasons, and some others can only be tightened.
Overriding with .htaccess
Overriding PHP directives is done through Apache (the webserver software we use), by placing a file called .htaccess in the directory for which you want to override the configuration for. Then you place the new settings in this file. Please note that all subdirectories will inherit these settings, so if you do not want that to happen, you will need to override the setting again in those subdirectories.
PHP configuration values are overridden with php_value and php_flag which respectively change values or flags. A flag is any option which has only two states (usually on/off), and other settings are values. It is very important to use the correct override command, otherwise they won't work properly. Both take two arguments - the first being the name of the directive to override, and the second being the value or flag which to override it to.
Here is what the syntax looks like:
php_value name "value" php_flag name flag
Practical Examples
Here are some real-world uses for this system.
Change the Error Reporting Level
If you would like to change the error reporting level, override the error_reporting directive. The following will specifically disable depreciated messages. Note that if something is depreciated, that means it won't be supported in later versions of PHP, so make sure not to develop any scripts which use depreciated functions and features!
php_value error_reporting "E_ALL ~E_DEPRECATED"
Disable Errors
If you'd like to turn off all PHP error reporting, use the following line. Note that errors and warning are very important, and tell you that something is genuinely wrong. Please do not simply ignore them, unless you specifically know what you are doing.
php_flag display_errors Off

