symfony-docker icon indicating copy to clipboard operation
symfony-docker copied to clipboard

php config file order

Open wizhippo opened this issue 5 months ago • 5 comments

As php takes the last ini value set, in frankenphp/conf.d

The order currently is:

app.dev.ini app.ini

Expected would be:

app.ini app.dev.ini

Should app.dev.ini be renamed so it is loaded after app.ini? Currently there is only one setting in app.dev.ini but more could be added and I believe the expected behavior would be it take precedence over settings in app.ini.

wizhippo avatar Jan 05 '24 16:01 wizhippo

Yes, a PR would be welcome. We currently have these : Capture d’écran 2024-02-25 à 19 36 37

maxhelias avatar Feb 25 '24 18:02 maxhelias

Is there any preference?

rename it to app.zzdev.ini or zzz-app.dev.ini?

wizhippo avatar Mar 21 '24 19:03 wizhippo

With number ? 00-app.ini & 01-app.dev.ini ?

maxhelias avatar Mar 21 '24 19:03 maxhelias

With number ? 00-app.ini & 01-app.dev.ini ?

Numbers will move them above the docker-php-ext-xyz.ini I would think we want our config to supersede them so I used the z prefix to move them to the bottom as php uses the last set value. So maybe z01-app.ini, z02-other.ini, ... Again normally the dev is loaded last so zzz-dev.ini seems most likely to be loaded last.

wizhippo avatar Mar 21 '24 21:03 wizhippo

You could also set the PHP_INI_SCAN_DIR environment variable to 2 paths. This will override the --with-config-file-scan-dir option in /usr/local/bin/php-config.

See: https://www.php.net/manual/en/configuration.file.php#configuration.file.scan

ENV PHP_INI_SCAN_DIR="$PHP_INI_DIR/conf.d:$PHP_INI_DIR/app.conf.d"

This way the conf.d directory is scanned first for ini files, and then the app.conf.d is scanned for ini files.

This way you can sort the app's ini files in numerical order.

/usr/local/etc/php/app.conf.d/10-app.ini
/usr/local/etc/php/app.conf.d/20-app.dev.ini  - or -  20-app.prod.ini

You can verify this with php --ini , which results in:

Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d:/usr/local/etc/php/app.conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/app.conf.d/app.ini

leroy0211 avatar Apr 25 '24 20:04 leroy0211