On 13 September 2013 20:06, Kevin Kinsey k...@daleco.biz wrote:
Date: Fri, 13 Sep 2013 11:40:27 +0100
From: Richard Quadling rquadl...@gmail.com
To: PHP General list php-general@lists.php.net
Subject: [PHP] Ini files for CLI only on non Win32 platform.
I've got an instance of PHP that is looking for additional ini files in
/etc/php.d
This seems to work well.
I now need to make one of the ini files only accessible if the SAPI is
CGI.
So, I renamed the file ... mv /etc/php.d/my.ini /etc/php.d/my-cgi.ini
If I do a ...
php --ini
I still see the ini file.
Is the -SAPI filtering performed on the additional files?
It doesn't seem to and I can't really tell from the dox if it is supposed
to.
Shouldn't the file name be php-cgi.ini ?
Manual: If php-SAPI.ini exists (where SAPI is the SAPI in use, so, for
example, php-cli.ini or
php-apache.ini), it is used instead of php.ini. The SAPI name can be
determined with php_sapi_name().
I'm in CLI mode here; note that my-cli.ini is ignored but php-cli.ini
is not:
[1016] Fri 13.Sep.2013 13:52:05
[kadmin@freebsd-devel][/www/data/]
php --ini
Configuration File (php.ini) Path: /usr/local/etc
Loaded Configuration File: /usr/local/etc/php.ini
Scan for additional .ini files in: /usr/local/etc/php
Additional .ini files parsed: /usr/local/etc/php/extensions.ini
[1017] Fri 13.Sep.2013 13:52:08
[kadmin@freebsd-devel][/www/data/]
sudo touch /usr/local/etc/php-cgi.ini
[1018] Fri 13.Sep.2013 13:52:26
[kadmin@freebsd-devel][/www/data/]
sudo touch /usr/local/etc/php-cli.ini
[1019] Fri 13.Sep.2013 13:52:32
[kadmin@freebsd-devel][/www/data/]
sudo touch /usr/local/etc/my-cli.ini
[1020] Fri 13.Sep.2013 13:52:44
[kadmin@freebsd-devel][/www/data/]
php --ini
Configuration File (php.ini) Path: /usr/local/etc
Loaded Configuration File: /usr/local/etc/php-cli.ini
Scan for additional .ini files in: /usr/local/etc/php
Additional .ini files parsed: /usr/local/etc/php/extensions.ini
I apologize if I'm missing the point or am obtuse or irrelevant;
I don't play with the INI files very often.
Kevin Kinsey
Ah! Yes.
The main ini file can be php-sapi.ini and the code is going to look for the
sapi specific file before the non specific file.
If you are also using an additional path (as the setup I'm working on
does), then ALL files in that path are included.
I just took a look at the source (and not sure why I didn't before) at
https://github.com/php/php-src/blob/master/main/php_ini.c#L565 and that
code deals with the sapi specific names.
After that, the additional path is scanned and all .ini files included. No
filtering by SAPI.
Using PHPRC environment variable sets a single ini file.
Using PHP_INI_SCAN_DIR environment variable overrides/sets the scanned
directory.
Just looking into adding a [SAPI] section for INI files (matching the
behaviour of [HOST] and [PATH].
--
Richard Quadling
Twitter : @RQuadling