views:

635

answers:

3

How do I include a php.ini file in another php.ini file?

+1  A: 

You can't. Read online pages:

The configuration file

SUMMARY: The configuration file (php.ini) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI version, it happens on every invocation.

.user.ini files

SUMMARY: In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). Only INI settings with the modes PHP_INI_PERDIR and PHP_INI_USER will be recognized in .user.ini-style INI files.

adatapost
I read those before posting, says nothing about including whether it is possible or not.
Itay Moav
+2  A: 

I don't think you can "include" .ini files from the main php.ini file.

One possible solution, though, might be to use this option on the configure line, when compiling PHP :

--with-config-file-scan-dir=PATH                                                        
    Set the path where to scan for configuration files

If this option is used at compile-time, PHP will look for every .ini file in this directory, in addition to the "normal" php.ini file.

I suppose this is what is used by Ubuntu, for instance, which uses a different .ini file for each downloaded extension, instead of modifying php.ini.

The path to the php.ini file being defined with this option, on the configure line :

--with-config-file-path=PATH                                                            
    Set the path in which to look for php.ini [PREFIX/lib]

Still, it probably means you'll have to re-compile PHP -- which is not that hard, btw -- the hardest part being to get the dependencies you need.

And, here is a post on the internals@ mailling-list that says the same thing as I do : config files and PHP_CONFIG_FILE_SCAN_DIR

Pascal MARTIN
A: 

You could try to simulate it making use of the ini_set function. But as the "man page" indicates, not all ini options can be changed using ini_set. It's definitely a useful function, though.

Skinniest Man