# Puppet Class: php::globals

Inherited by:
  php::params

Defined in:
  manifests/globals.pp

## Overview

Parameters:

- php_version (`Optional[Pattern[/^[57].[0-9]/]]`) (defaults to: `undef`)
- config_root (`Optional[Stdlib::Absolutepath]`) (defaults to: `undef`)
- fpm_pid_file (`Optional[Stdlib::Absolutepath]`) (defaults to: `undef`)

    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    # File 'manifests/globals.pp', line 14

    class php::globals (
      Optional[Pattern[/^[57].[0-9]/]] $php_version = undef,
      Optional[Stdlib::Absolutepath] $config_root   = undef,
      Optional[Stdlib::Absolutepath] $fpm_pid_file  = undef,
    ) {

      $default_php_version = $facts['os']['family'] ? {
        'Debian' => $facts['os']['name'] ? {
          'Ubuntu' => $facts['os']['release']['full'] ? {
            /^(1[67].04)$/ => '7.0',
            default => '5.x',
          },
          default => '5.x',
        },
        default => '5.x',
      }

      $globals_php_version = pick($php_version, $default_php_version)

      case $facts['os']['family'] {
        'Debian': {
          if $facts['os']['name'] == 'Ubuntu' {
            case $globals_php_version {
              /^5\.4/: {
                $default_config_root  = '/etc/php5'
                $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
                $fpm_error_log        = '/var/log/php5-fpm.log'
                $fpm_service_name     = 'php5-fpm'
                $ext_tool_enable      = '/usr/sbin/php5enmod'
                $ext_tool_query       = '/usr/sbin/php5query'
                $package_prefix       = 'php5-'
              }
              /^[57].[0-9]/: {
                $default_config_root  = "/etc/php/${globals_php_version}"
                $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
                $fpm_error_log        = "/var/log/php${globals_php_version}-fpm.log"
                $fpm_service_name     = "php${globals_php_version}-fpm"
                $ext_tool_enable      = "/usr/sbin/phpenmod -v ${globals_php_version}"
                $ext_tool_query       = "/usr/sbin/phpquery -v ${globals_php_version}"
                $package_prefix       = "php${globals_php_version}-"
              }
              default: {
                # Default php installation from Ubuntu official repository use the following paths until 16.04
                # For PPA please use the $php_version to override it.
                $default_config_root  = '/etc/php5'
                $default_fpm_pid_file = '/var/run/php5-fpm.pid'
                $fpm_error_log        = '/var/log/php5-fpm.log'
                $fpm_service_name     = 'php5-fpm'
                $ext_tool_enable      = '/usr/sbin/php5enmod'
                $ext_tool_query       = '/usr/sbin/php5query'
                $package_prefix       = 'php5-'
              }
            }
          } else {
            case $globals_php_version {
              /^7/: {
                $default_config_root  = "/etc/php/${globals_php_version}"
                $default_fpm_pid_file = "/var/run/php/php${globals_php_version}-fpm.pid"
                $fpm_error_log        = "/var/log/php${globals_php_version}-fpm.log"
                $fpm_service_name     = "php${globals_php_version}-fpm"
                $ext_tool_enable      = "/usr/sbin/phpenmod -v ${globals_php_version}"
                $ext_tool_query       = "/usr/sbin/phpquery -v ${globals_php_version}"
                $package_prefix       = "php${globals_php_version}-"
              }
              default: {
                $default_config_root  = '/etc/php5'
                $default_fpm_pid_file = '/var/run/php5-fpm.pid'
                $fpm_error_log        = '/var/log/php5-fpm.log'
                $fpm_service_name     = 'php5-fpm'
                $ext_tool_enable      = '/usr/sbin/php5enmod'
                $ext_tool_query       = '/usr/sbin/php5query'
                $package_prefix       = 'php5-'
              }
            }
          }
        }
        'Suse': {
          case $globals_php_version {
            /^7/: {
              $default_config_root  = '/etc/php7'
              $package_prefix       = 'php7-'
              $default_fpm_pid_file = '/var/run/php7-fpm.pid'
              $fpm_error_log        = '/var/log/php7-fpm.log'
            }
            default: {
              $default_config_root  = '/etc/php5'
              $package_prefix       = 'php5-'
              $default_fpm_pid_file = '/var/run/php5-fpm.pid'
              $fpm_error_log        = '/var/log/php5-fpm.log'
            }
          }
        }
        'RedHat': {
          $default_config_root  = '/etc/php.d'
          $default_fpm_pid_file = '/var/run/php-fpm/php-fpm.pid'
        }
        'FreeBSD': {
          $default_config_root  = '/usr/local/etc'
          $default_fpm_pid_file = '/var/run/php-fpm.pid'
        }
        'Archlinux': {
          $default_config_root  =  '/etc/php'
          $default_fpm_pid_file = '/run/php-fpm/php-fpm.pid'
        }
        default: {
          fail("Unsupported osfamily: ${facts['os']['family']}")
        }
      }

      $globals_config_root = pick($config_root, $default_config_root)

      $globals_fpm_pid_file = pick($fpm_pid_file, $default_fpm_pid_file)
    }