Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php config file order #538

Closed
wizhippo opened this issue Jan 5, 2024 · 5 comments · Fixed by #617
Closed

php config file order #538

wizhippo opened this issue Jan 5, 2024 · 5 comments · Fixed by #617

Comments

@wizhippo
Copy link

wizhippo commented Jan 5, 2024

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.

@maxhelias
Copy link
Collaborator

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

@wizhippo
Copy link
Author

Is there any preference?

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

@maxhelias
Copy link
Collaborator

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

wizhippo added a commit to wizhippo/symfony-docker that referenced this issue Mar 21, 2024
@wizhippo
Copy link
Author

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.

@leroy0211
Copy link
Contributor

leroy0211 commented Apr 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants