Skip to content

Commit

Permalink
Merge pull request #54 from Mayflower/feature/pecl-zend-extensions
Browse files Browse the repository at this point in the history
Add support to load pecl extensions as zend extensions
  • Loading branch information
globin committed Jan 9, 2015
2 parents af6a4d3 + 5379f73 commit 6db6453
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
19 changes: 17 additions & 2 deletions manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
# The pecl source channel to install pecl package from
#
# [*header_packages*]
# system packages dependecies to install for extensions (e.g. for
# System packages dependecies to install for extensions (e.g. for
# memcached libmemcached-dev on debian)
#
# [*zend*]
# Boolean parameter, whether to load extension as zend_extension.
# This can only be set for pecl modules. Defaults to false.
#
# [*settings*]
# Nested hash of global config parameters for php.ini
#
Expand All @@ -43,6 +47,7 @@
$package_prefix = $php::package_prefix,
$header_packages = [],
$compiler_packages = $php::params::compiler_packages,
$zend = false,
$settings = {},
) {

Expand All @@ -53,6 +58,7 @@
validate_string($ensure)
validate_string($package_prefix)
validate_array($header_packages)
validate_bool($zend)

if $provider != 'none' {
if $provider == 'pecl' {
Expand Down Expand Up @@ -87,9 +93,18 @@
}
}

if $provider != 'pecl' and $zend {
fail('You can only use the zend parameter for pecl PHP extensions!')
}

$extension_key = $zend ? {
true => 'zend_extension',
false => 'extension',
}

$lowercase_title = downcase($title)
$real_settings = $provider ? {
'pecl' => deep_merge({'extension' => "${name}.so"}, $settings),
'pecl' => deep_merge({ "${extension_key}" => "${name}.so" }, $settings),
default => $settings
}
$php_settings_file = "${php::params::config_root_ini}/${lowercase_title}.ini"
Expand Down
25 changes: 25 additions & 0 deletions spec/defines/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
}
end

context 'non-pecl extensions cannot be configured as zend' do
let(:title) { 'xdebug' }
let(:params) {{
:zend => true,
}}

it { expect { should raise_error(Puppet::Error) }}
end

context 'pecl installation' do
let(:title) { 'json' }
let(:params) {{
Expand All @@ -50,6 +59,22 @@
}
end

context 'pecl extensions can be configured as zend' do
let(:title) { 'xdebug' }
let(:params) {{
:provider => 'pecl',
:zend => true
}}

it {
should contain_php__config('xdebug').with({
:config => {
'zend_extension' => 'xdebug.so'
}
})
}
end

context 'on Debian' do
let(:facts) { {
:osfamily => 'Debian',
Expand Down

0 comments on commit 6db6453

Please sign in to comment.