Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Support PHP 8 #2115

Open
geerlingguy opened this issue Nov 28, 2020 · 19 comments
Open

Support PHP 8 #2115

geerlingguy opened this issue Nov 28, 2020 · 19 comments

Comments

@geerlingguy
Copy link
Owner

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.

@kom177
Copy link

kom177 commented Jul 27, 2021

Will there be next release with PHP 8 support?

@geerlingguy
Copy link
Owner Author

@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: geerlingguy/drupal-container#32 and https://www.drupal.org/project/drupal/issues/3156651

@kom177
Copy link

kom177 commented Jul 27, 2021

"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

@geerlingguy
Copy link
Owner Author

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?

@kom177
Copy link

kom177 commented Jul 28, 2021

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
Copy link

kom177 commented Dec 20, 2021

What could we do manually to enable PHP 8 support?

@geerlingguy
Copy link
Owner Author

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

@kom177
Copy link

kom177 commented Dec 23, 2021

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).

@TipiT
Copy link

TipiT commented Jan 21, 2022

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.

@kom177
Copy link

kom177 commented Jan 21, 2022

@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

@TipiT
Copy link

TipiT commented Jan 21, 2022

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. :)

@zar-wtag
Copy link

zar-wtag commented Feb 8, 2022

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.

@florianmuellerCH
Copy link

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 ?

@geerlingguy
Copy link
Owner Author

@florianmuellerCH - I probably won't work on it; see #2164

@emb03
Copy link

emb03 commented Jul 14, 2022

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

@Harishm04
Copy link

Harishm04 commented Jul 15, 2022

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 ?

@marcelovani
Copy link

I got the same issue about php8.0-json

@marcelovani
Copy link

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.

@Harishm04
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants