Skip to content

Commit

Permalink
feat(ini) support different settings for php.ini
Browse files Browse the repository at this point in the history
When php:version is a list, a dict with settings for different
versions can be added under ini key of cli and fpm:config keys

php:
  fpm:
    config:
      ini:
        settings:
          # global settings
        '5.6':
          # settings for 5.6 only
  cli:
    ini:
      settings:
        # global settings
      '5.6':
        # settings for 5.6 only
  • Loading branch information
scambra committed Feb 19, 2020
1 parent e6393c7 commit c7da18d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
17 changes: 16 additions & 1 deletion php/cli/ini.sls
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@
{%- for version in pillar_php_version %}
{%- set first_version = pillar_php_version[0]|string %}
{%- set ini = php.lookup.cli.ini|replace(first_version, version) %}
{%- if version in php.cli.ini %}
{%- set settings_versioned = {} %}
{%- for key, value in settings.items() %}
{%- do settings_versioned.update({key: value.copy()}) %}
{%- endfor %}
{%- for key, value in php.cli.ini[version].items() %}
{%- if settings_versioned[key] is defined %}
{%- do settings_versioned[key].update(value) %}
{%- else %}
{%- do settings_versioned.update({key: value}) %}
{%- endif %}
{%- endfor %}
{%- endif %}
php_cli_ini_{{ version }}:
{{ php_ini(ini,
'php_cli_ini_' ~ version,
php.cli.ini.opts,
settings
settings_versioned | default(settings)
) }}
{%- endfor %}
{%- else %}
Expand Down
14 changes: 14 additions & 0 deletions php/fpm/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
{%- set conf = php.lookup.fpm.conf|replace(first_version, version) %}
{%- set pools = php.lookup.fpm.pools|replace(first_version, version) %}
{%- if version in php.fpm.config.ini %}
{%- set ini_settings_versioned = {} %}
{%- for key, value in ini_settings.items() %}
{%- do ini_settings_versioned.update({key: value.copy()}) %}
{%- endfor %}
{%- for key, value in php.fpm.config.ini[version].items() %}
{%- if ini_settings_versioned[key] is defined %}
{%- do ini_settings_versioned[key].update(value) %}
{%- else %}
{%- do ini_settings_versioned.update({key: value}) %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- for key, value in conf_settings.items() %}
{%- if value is string %}
{%- do conf_settings.update({key: value.replace(first_version, version)}) %}
Expand Down
10 changes: 10 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ php:
engine: 'Off'
extension_dir: '/usr/lib/php/modules/'
extension: [pdo_mysql.so, iconv.so, openssl.so]
# if a list of versions is set in php:version, each version
# may have different settings
# '7.2':
# PHP:
# short_open_tag: 'On'

# options to manage the php-fpm conf file
conf:
Expand Down Expand Up @@ -169,6 +174,11 @@ php:
settings:
PHP:
engine: 'Off'
# if a list of versions is set in php:version, each version
# may have different settings
# '7.2':
# PHP:
# short_open_tag: 'On'

# php-xcache settings
xcache:
Expand Down

0 comments on commit c7da18d

Please sign in to comment.