Php_extensions_custom must be formatted as dicts

If you try to add custom PHP extensions via group_vars/all/main.yml using the syntax suggested in several answers (e.g. to install ImageMagick)…

php_extensions_custom:
  - php-imagick

You’ll get this error:

The following variables must be formatted as dicts:
  - php_extensions_custom

This is the right syntax:

php_extensions_custom:
  php-imagick: "{{ apt_package_state }}"

Bye :wink:

6 Likes

I ran into this when updating a copy of Trellis for a site that needed soap. I figured it out, too, but I wonder if a commented-out example would help future generations.

1 Like

Indeed.

Can anyone explain what that apt_package_state part does?

2 Likes

Sorry for reviving this discussion, but will WordPress use ImageMagick/Imagick instead of PHP GD?
Must a plugin be used for forcing WordPress to use ImageMagick/Imagick instead of PHP GD?

Three years later, I needed php-gd for a plugin which relies on createimagefromstring().

While setting php_extensions_custom to php-gd: "{{ apt_package_state }}" output a success: changed: [134.122.127.xxx] => (item=php-gd), it DID NOT install the file(s) into /etc/php/8.0/mods-available/.

It needed to be php8.0-gd: "{{ apt_package_state }}"

I was hoping to use "php{{ php_version }}-gd": "{{ apt_package_state }}", but that tried to install, literally and:

No package matching 'php{{ php_version }}-gd' is available

Hopefully that’s worth reviving this dusty old thread for.

Also curious about this. Right now I’m just statically setting it to be the current php version I’m using. But that’s hardly ideal.

Looks like custom extensions weren’t fully integrated into the new method of supporting multiple PHP versions since they can’t be version specific. I’d suggest opening an issue so we can look into solutions.

1 Like