-
GitHub stars
Configuring PHP
Trellis will setup PHP and extensions suitable for a WordPress environment out of the box, but you may want to customise for your own setups. For example, you may want to change the version of PHP or add an extension.
Note
If you make a change to the PHP settings, you will need to reprovision your environments before seeing any changes. You can use --tags=php
to only run the required role(s). Be sure to reprovision all the environments you need to.
Change the version of PHP
In group_vars/all/main.yml
, set the value of php_version
to the version you're working with.
e.g. to use PHP 8.1: php_version: "8.1"
As of #1560 Trellis supports 7.4 & 8.1 up to 8.4. Newer versions may work when released but may not have been tested by the community yet - you can help by testing yourself and reporting your progress on Roots Discourse.
Changing the default extensions
Trellis will look for a version-specific override file before falling back to the default PHP extensions. If you'd like to change the extensions installed on your environments, duplicate the roles/php/vars/version-specific-defaults.yml
file and rename it to the version of PHP you are targetting.
Example
To target PHP 8.4, duplicate and rename so that your folder looks like this:
├── ...other folders...
└── roles/
├── ...other folders...
└── php/
├── ...other folders...
└── vars/
+ ├── 8.4.yml
└── version-specific-defaults.yml
In your 8.4.yml
file you can then set the extensions you'd like to use. Include all extensions from the defaults file unless you have a good reason not to, remembering that WP requires some extensions to work.
php_extensions_default:
php8.4-bcmath: "{{ apt_package_state }}"
php8.4-example: "{{ apt_package_state }}"
# etc.
Last updated
Support Roots
Help us continue to build and maintain our open source projects. We’re a small team of independent developers and every little bit helps.
Sponsor Roots on GitHub