Defined Type: php::extension

Defined in:
modules/php/manifests/extension.pp

Overview

Parameters:

  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • package_name (String) (defaults to: "php-${title}")
  • priority (Integer[0,99]) (defaults to: 20)
  • config (Optional[Hash]) (defaults to: undef)
  • sapis (Optional[Array[Php::Sapi]]) (defaults to: undef)


1
2
3
4
5
6
7
8
9
10
11
12
13
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
# File 'modules/php/manifests/extension.pp', line 1

define php::extension(
    Wmflib::Ensure $ensure = 'present',
    String $package_name = "php-${title}",
    Integer[0,99] $priority = 20,
    Optional[Hash] $config = undef,
    Optional[Array[Php::Sapi]] $sapis = undef,
) {
    if !defined(Class['php']) {
        fail('php::extension is not meant to be used before the php class is declared.')
    }

    $_sapis = pick($sapis, $php::sapis)
    $_config = pick($config, {'extension' => "${title}.so"})
    $title_safe  = regsubst($title, '[\W]', '-', 'G')
    $mod_file = "${php::config_dir}/mods-available/${title_safe}.ini"
    $conf_file   = sprintf('%02d-%s.%s', $priority, $title_safe, 'ini')

    # The config file needs to be present before package installation so
    # the resulting installed link will have the correct priority, and
    # no cleanup will be needed.
    # We also add the relevant tags for allowing services to subscribe to this file
    file { $mod_file:
        ensure  => $ensure,
        content => template('php/extension.ini.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        tag     => prefix($_sapis, 'php::config::')
    }

    if $package_name != '' {
        package{ $package_name:
            ensure  => $ensure,
            require => File[$mod_file],
            tag     => prefix($_sapis, 'php::package::')
        }
    }

    # If your provided list of PHP SAPIs is not compatible with the installed SAPIs
    # the catalog will fail to apply correctly.
    $_sapis.each |$sapi| {
        file { "${php::config_dir}/${sapi}/conf.d/${conf_file}":
            ensure => ensure_link($ensure),
            target => $mod_file,
        }
    }
}