Setting PHP Include Path on a per site basis?
include, php
Solution
If you're using apache as a webserver you can override (if you allow it) settings using .htaccess files. See the PHP manual for details.
Basically you put a file called .htaccess in your website root, which contains some PHP `ini` values. Provided you configured Apache to allow overrides, this site will use all values in your PHP config, + the values you specify in the .htaccess file.
Can be used only with `PHP_INI_ALL` and `PHP_INI_PERDIR` type directives
as stated in the page I linked. If you click through to the full listing, you see that the include path is a `PHP_INI_ALL` directive.
Problem
I can set the PHP include path in the `php.ini`: ``` include_path = /path/to/site/includes/ ``` But then other websites are affected so that is no good. I can set the PHP include in the start of every file: ``` $path = '/path/to/site/includes/'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); ``` But that seems like bad practice and clutters things up. So I can make an include of that and then include it into every file: ``` include 'includes/config.php'; ``` or ``` include '../includes/config.php'; ``` This is what I'm doing right now, but the include path of `config.php` will change depending on what is including it. Is there a better way? Does it matter?