Skip to content

Commit

Permalink
better PHP docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjn authored Feb 27, 2024
1 parent 45062ea commit 27c7b41
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions docs/en-US/adding-a-new-site/changing-php-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@ description: VVV supports the php option in the sites section of config/config.y
permalink: /docs/en-US/adding-a-new-site/changing-php-version/
---

You can set the PHP version in `config/config.yml` when defining a site. To do this, use the `php` option to specify the PHP version in Nginx and the provisioner. VVV also needs to be told to install that version of PHP using the `extensions` section.
You can set the PHP version used by a site in `config/config.yml` by taking these 2 steps:

Here’s an example that uses PHP v8.0:
1. Make sure the PHP version you want is installed in the `extensions` section. For example if you want to use PHP 9.6 you would add the `php96` extension.
- If you do not do this you will get warnings in the provisioner and changing the PHP version will fail.
2. Use the `php` option to specify the PHP version the site should use. E.g. `php: 9.6` for PHP v9.6

Here’s an example that uses PHP v8.3:

```yaml
sites:
phpeight:
repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template.git
php: 8.0 # Don't forget to add php80 to the extensions
php: 8.3
hosts:
- phpeight.test

extensions:
core:
- php80 # Not optional
- php83 # Not optional
```
**Important:*** If you do not update the `extensions` section to add the PHP version then this will not work. VVV will not auto-install PHP versions for you.

**Tip:** If you add the `php` utility, it will install all available versions of PHP, skipping this step.

**Warning:** This will not work if `set $upstream {upstream};` is removed from the nginx config.

In this example, we have changed the `phpeightone` site to use PHP 8.1, and the `phpeighttwo-develop` site to use PHP 8.2:
In this example, we've instructed VVV to install PHP v8.1 and v8.2 in the `extensions` section, then we changed the `phpeightone` site to use PHP 8.1, and the `phpeighttwo-develop` site to use PHP 8.2:

```yaml
sites:
Expand Down Expand Up @@ -72,7 +74,7 @@ That site is now using PHP v8.1, even if `php:` or `nginx_upstream:` are set in

## Troubleshooting

- If your VVV install is old, you may have a `utilities` section, this was renamed to `extensions`. Do not have both at the same time.
- If your VVV install is old, you may have a `utilities` section, this was renamed to `extensions`. Update VVV and replace `utilities:` with `extensions:`, do not have both at the same time.
- If you ask VVV to use a version of PHP that isn't installed, provisioning may fail, and your site will not use the requested version. Add the extension for that PHP as shown in the examples and reprovision.
- If VVV tells you `Chosen PHP version doesn't exist in this environment` when provisioning then you did not install the needed PHP version, see the previous bullet point.
- Older versions of PHP used the `nginx_upstream` option to override the PHP version. The new `php:` parameter does this and fixes the PHP version during provisioning and in the dashboard.
Expand Down

0 comments on commit 27c7b41

Please sign in to comment.