# Adding a PHP extension without editing the php role directly?

**URL:** https://discourse.roots.io/t/adding-a-php-extension-without-editing-the-php-role-directly/9662
**Category:** trellis
**Created:** 2017-05-23T15:34:00Z
**Posts:** 2

## Post 1 by @MWDelaney — 2017-05-23T15:34:00Z

Hey y’all,  
I have a site that needs SOAP installed. I managed to install it successfully using [this reference](https://github.com/roots/trellis/pull/503)

In `trellis/roles/php/defaults/main.yml` I added

```
php_extensions_custom:
  - php7.1-soap
```

So that’s all good and working, but I’m wondering if there’s a less invasive place to put this. Can it be included in `group_vars` somehow?

Thanks!

---

## Post 2 by @fullyint — 2017-05-24T05:11:56Z

You nailed it. You may put that exact snippet in any `group_vars` file you choose. I’d probably choose `group_vars/all/main.yml`.

Regarding the defaults in any `trellis/roles/<rolename>/defaults/main.yml` files, they have the lowest [priority](http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable) and they live to be overridden by your redefinition in `group_vars` files.

Trellis has begun to use a pattern to make it easier to override some defaults ([roots/trellis#735](https://github.com/roots/trellis/pull/735) and [roots/trellis#787](https://github.com/roots/trellis/pull/787)). The combo of [`php_extensions_default` + `php_extensions_custom`](https://github.com/roots/trellis/blob/2773baa313a496227eafbe294ca5b30d484c232a/roles/php/defaults/main.yml#L4-L19) make it so if you’d like to add to the list of php extensions, you only need to redefine `php_extensions_custom` instead of the entire list of `php_extensions`.
