Puppet Class: php::composer

Defined in:
puppet/modules/php/manifests/composer.pp

Overview

Class: php::composer

Provision and update Composer PHP dependency manager.

Parameters

home

Composer home directory (COMPOSER_HOME). Default '/vagrant/cache/composer'

cache_dir

Composer cache directory (COMPOSER_CACHE_DIR). Default '/vagrant/cache/composer'

Parameters:

  • home (Any) (defaults to: '/vagrant/cache/composer')
  • cache_dir (Any) (defaults to: '/vagrant/cache/composer')


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
# File 'puppet/modules/php/manifests/composer.pp', line 14

class php::composer (
    $home        = '/vagrant/cache/composer',
    $cache_dir   = '/vagrant/cache/composer',
) {
    $bin = '/usr/local/bin/composer'

    exec { 'download_composer':
        command => "curl https://getcomposer.org/composer.phar -o ${bin}",
        unless  => "php -r 'try { Phar::loadPhar(\"${bin}\"); exit(0); } catch(Exception \$e) { exit(1); }'",
        require => [
            Package['curl'],
            Class['php::package'],
        ],
    }

    file { '/usr/local/bin/composer':
        ensure  => file,
        owner   => 'root',
        group   => 'staff',
        mode    => '0755',
        require => Exec['download_composer'],
    }

    exec { 'update_composer':
        command     => '/usr/local/bin/composer self-update',
        environment => [
          "COMPOSER_HOME=${home}",
          "COMPOSER_CACHE_DIR=${cache_dir}",
          'COMPOSER_NO_INTERACTION=1',
        ],
        require     => [
            File['/usr/local/bin/composer'],
            Class['php::package'],
        ],
        schedule    => 'weekly',
    }

    env::var { 'COMPOSER_CACHE_DIR':
        value => $cache_dir,
    }

    env::profile_script { 'add composer global bin to path':
        content => 'export PATH=$PATH:~/.composer/vendor/bin',
    }
}