# Php_extensions_custom must be formatted as dicts

**URL:** https://discourse.roots.io/t/php-extensions-custom-must-be-formatted-as-dicts/11039
**Category:** trellis
**Tags:** ansible
**Created:** 2017-11-30T17:35:06Z
**Posts:** 9

## Post 1 by @flocca — 2017-11-30T17:35:06Z

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:

---

## Post 2 by @MWDelaney — 2017-11-30T18:11:56Z

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.

---

## Post 3 by @franzliedke — 2017-12-11T07:29:14Z

Indeed.

Can anyone explain what that `apt_package_state` part does?

---

## Post 4 by @strarsis — 2019-07-19T09:44:41Z

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?

---

## Post 5 by @mZoo — 2022-08-12T16:34:40Z

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.

---

## Post 7 by @broskees — 2022-10-21T13:55:24Z

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.

---

## Post 8 by @swalkinshaw — 2022-10-21T15:19:37Z

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.

---

## Post 9 by @andronocean — 2024-10-22T13:19:38Z

To anyone else who finds this dusty old thread: you’ll be happy to know that the syntax `"php{{ php_version }}-gd": "{{ apt_package_state }}"` works correctly nowadays (tested with Trellis 1.23.0). Not sure when it changed, but yay :grin:
