views:

2617

answers:

4

I want to set the include_path variable in my php.ini file. (C:\Windows\php.ini)

But, I want different include_path values for different sites hosted on the same Windows server. How can I do this?

+1  A: 

Unfortunately, I don't think you can. However, some webservers can change PHP settings on an individual basis... Apache using mod_php has the php_value setting that you can set on various virtual hosts, IIS might have something similar, but I'm not sure.

set_include_path can also override the include path at runtime.

P.S. TF2 Engineer for the win.

R. Bemrose
+2  A: 

http://php.net/manual/en/configuration.php says:

php.ini is searched in these locations (in order):

. . .

You can review this list and see if one of the techniques helps in your case. For example, you can set the environment variable PHPRC, or you can put a different php.ini file in each current working directory, assuming each virtual host has a distinct cwd.

Note that when using Apache and mod_php, or other module embedding PHP in the web server (e.g. FastCGI), the php.ini file is read once, at web server startup. When you use PHP in a CGI manner, the php.ini file is read during every web request, so you have more opportunity to use a different php.ini.

Bill Karwin
+4  A: 

You can set the php include_path from an .htaccess file, assuming you have the correct AllowOverride settings in your httpd.conf file. Here's an example how:

.htaccess

php_value include_path "d:\path\to\include"
tj111
The question never mentions Apache.
R. Bemrose
The question DOES mention Windows.
Zack Peterson
works like charm!
Sabya
+2  A: 

As I understand the question, its more important to have individual include paths for each server/site then multiple php.ini files? Id say keep your code in PHP as far as possible.

Then you can just set the include_path with set_include_path or ini_set.

In apache you can set it in virtual domain or .htaccess file with php_value include_path "<first path to look>:<second path>:<etc>:.". IIS probably has a similar method.

OIS