drupal-vm icon indicating copy to clipboard operation
drupal-vm copied to clipboard

Support PHP 8

Open geerlingguy opened this issue 3 years ago • 19 comments

Issue Type

  • Feature Idea

Summary

PHP 8.0.0 was released yesterday: https://www.php.net/archive/2020.php#2020-11-26-3

I will need to update some roles to support it, but it would be nice to be able to support it, and probably bump the default version of PHP to 7.4 now.

geerlingguy avatar Nov 28 '20 05:11 geerlingguy

Will there be next release with PHP 8 support?

kom177 avatar Jul 27 '21 08:07 kom177

@kom177 - As much as I would like to do it (I'm already using PHP 8 in some systems elsewhere), Drupal itself doesn't yet support PHP 8 :(

See: https://github.com/geerlingguy/drupal-container/issues/32 and https://www.drupal.org/project/drupal/issues/3156651

geerlingguy avatar Jul 27 '21 20:07 geerlingguy

"PHP 8 is supported from Drupal 9.1.0" https://www.drupal.org/docs/understanding-drupal/how-drupal-9-was-made-and-what-is-included/environment-requirements-of

kom177 avatar Jul 27 '21 20:07 kom177

Hmm... the last time I tried installing it (June) I was running into errors. Maybe it was Drush or some other dependency that still wasn't compatible?

geerlingguy avatar Jul 27 '21 20:07 geerlingguy

I've stress-tested production site on PHP 8.0.3 and everything worked fine in a week (D9.1.10, D9.2.0 and D9.2.2, core-recommended project with more than 50 contrib modules). But Drush is configured to run under PHP 7.3. I'll try to reconfigure it. UPD. I've changed all PHPs on remote server from 7.4 to 8.0 (for site on D9.2.2, CLI and aliases for drush and composer). Everything seems to work "as designed".

kom177 avatar Jul 28 '21 10:07 kom177

What could we do manually to enable PHP 8 support?

kom177 avatar Dec 20 '21 10:12 kom177

The php-versions role supports PHP 8, so technically if you're on Ubuntu 18.04 or 20.04, or Debian 10/11, you could set php_version to 8.0 or maybe 8.1 (haven't tried that) and it should work... https://github.com/geerlingguy/ansible-role-php-versions

geerlingguy avatar Dec 20 '21 15:12 geerlingguy

Jeff, thanks, everything works! (For those who want to switch to PHP 8.0 - don't forget to replace files from release 6.0.4 to very last dev version in provisioning folder).

kom177 avatar Dec 23 '21 20:12 kom177

For new projects and D9 PHP 8 is recommended: https://www.drupal.org/docs/system-requirements/php-requirements

Would be nice to at least have instructions how to get PHP 8.0 provisioned in DrupalVM.

TipiT avatar Jan 21 '22 10:01 TipiT

@TipiT

  1. Download latest drupalvm code https://github.com/geerlingguy/drupal-vm/archive/refs/heads/master.zip and use it as a whole, or replace your provisioning folder
  2. Change in provisioning/roles/geerlingguy.php-versions/defaults/main.yml php_version: '7.4' to '8.0'
  3. Change in your config.yml php_version: "7.4" to "8.0"
  4. Vagrant reload --provision, or better vagrant destroy / vagrant up
  5. Enjoy

kom177 avatar Jan 21 '22 11:01 kom177

Actually this was (approximately) what I did:

  1. Change base box in config.yml: vagrant_box: geerlingguy/ubuntu2004. Just to get the PHP8 from Ubuntu repo.
  2. Change the php_version: "8.0"
  3. Add the role to installed_extras: - php-versions
  4. Add the php-versions role: ansible-galaxy install --roles-path /your/projects/drupal-vm/provisioning/roles geerlingguy.php-versions
  5. Add a task like provisioning/tasks/install-php8.yml that is like this `- name: Include geerlingguy.php-versions role

include_role:

name: geerlingguy.php-versions

when: '"php-versions" in installed_extras'`

  1. vagrant up --provision

Looks like it's working but I think only changing the php_version: "8.0" could be enough. :)

TipiT avatar Jan 21 '22 11:01 TipiT

Hi @TipiT Glad to hear that you were able to get it working. Will it be possible for your to share a repo where it is working with all the configuration changes in a single commit?

I am kind of struggling to place which to where.

Thanks.

zar-wtag avatar Feb 08 '22 07:02 zar-wtag

https://www.drupal.org/project/drupal/issues/3156651 is now closed / fixed and it would be nice to have PHP 8.0 or even 8.1 out of the box, as I cannot învest too much time in fiddeling with other box versions. Is this planned for the near future @geerlingguy ?

florianmuellerCH avatar Mar 13 '22 21:03 florianmuellerCH

@florianmuellerCH - I probably won't work on it; see https://github.com/geerlingguy/drupal-vm/issues/2164

geerlingguy avatar Mar 13 '22 21:03 geerlingguy

Need help with using php 8 on DrupalVM, these instructions are not clear to me how to do this...

emb03 avatar Jul 14 '22 15:07 emb03

Hi @geerlingguy / @TipiT Could you pls provide more info on updating to PHP 8 in DrupalVM . After updating php_version: "8.0" in box/config.yml and running vagrant reload -- provisioning it throws error as below, failed: E: Package 'php8.0-json' has no installation candidate\n", "rc": 100, "stderr": "E: Package 'php8.0-json' has no installation candidate\n"

I understand that PHP Json package is now part of Core. But how do we exclude this package from being executed , do we need to include the package "geerlingguy/ansible-role-php-versions" along with DRUPAL VM package to support PHP 8 version ?

Harishm04 avatar Jul 15 '22 08:07 Harishm04

I got the same issue about php8.0-json

marcelovani avatar Aug 03 '22 14:08 marcelovani

I managed to get this working with these steps:

1 - Since there is no release for the PHP 8 code (https://github.com/geerlingguy/ansible-role-php-versions/blob/master/vars/Debian.yml#L47) I had to require the master branch as 6.0.5 using this command: composer require --dev "geerlingguy/drupal-vm:dev-master as 6.0.5"

2 - Updated my config.yml with

vagrant_box: geerlingguy/ubuntu2004
php_version: '8.0'

3 - Manually removed this line from this file that is in the vendor folder https://github.com/geerlingguy/ansible-role-php-versions/blob/master/vars/Debian.yml#L34

4 - Ran vagrant reload --provision

I hope this is helpful.

I wonder if someone could create a new release of drupal-vm to remove step 1. And maybe make the php*-json extension optional based on php version.

marcelovani avatar Aug 03 '22 15:08 marcelovani

Thanks for the response @marcelovani .. I have also made similar steps to make it work like just following step 3 alone works for me .. I was just looking for option where we don't have to modify files inside Vendor folder. Tried to create a separate git repo for geerlingguy/drupal-vm in local repo but didn't work since I have acquia/blt-drupal-vm module which requires stable 5 || 6 version of drupal-vm package.

Harishm04 avatar Aug 10 '22 06:08 Harishm04