Problem/Motivation

The composer.json restricts this to PHP ~7.1

Steps to reproduce

Attempt to `composer require drupal/currency` while using PHP 8

Proposed resolution

Adjust the composer.json

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork currency-3223997

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tim.plunkett created an issue. See original summary.

tjtj’s picture

I need this also!

scott_euser’s picture

Status: Active » Reviewed & tested by the community
Issue tags: +Drupal10

Thanks for this, works well! No issues found running this in D9 on PHP8 for the last couple months with this patch.

scott_euser’s picture

For anyone trying to get this working at the moment until its merged (and until its dependencies are merged), we used this in our composer:

"drupal/currency": "dev-3223997-allow-php-8 as 3.3.0",
"commercie/currency": "dev-support_php_8 as 1.1.2",
"commercie/currency-exchange": "dev-php-8-support as 1.2.0",

(both the commercie dependencies similarly support PHP 8 only via the pull requests in the issue queues).

maxilein’s picture

Could you finally please merge this into dev!
Thank you

christophedg’s picture

Merging into dev would be really helpful for me too! Thanks in advance

NewZeal’s picture

I am able to get all the libraries to pass composer validation with the following entries:

        "commercie/currency": {
          "type": "package",
          "package": {
              "name": "commercie/currency",
              "version": "1.1.2",
              "type": "library",
              "source": {
                  "url": "git@github.com:TomKeyte/currency.git",
                  "type": "git",
                  "reference": "d38d1b7ffd3e21f13b2e9d15b07879b64059ad84"
              }
          }
        },
        "commercie/currency-exchange": {
          "type": "package",
          "package": {
              "name": "commercie/currency-exchange",
              "version": "1.2",
              "type": "drupal-library",
              "source": {
                  "url": "git@github.com:mohamed-nabawy/currency-exchange.git",
                  "type": "git",
                  "reference": "bf0d5905036df23e03b0307f83d0f90a50e839d4"
              }
          }
        },
        "drupal/currency": {
          "type": "package",
          "package": {
              "name": "drupal/currency",
              "version": "dev-custom",
              "type": "drupal-module",
              "source": {
                  "url": "git@git.drupal.org:issue/currency-3223997.git",
                  "type": "git",
                  "reference": "3223997-allow-php-8"
              }
          }
        },
        "commercie/currency": "^1.1",
        "commercie/currency-exchange": "^1.2",
        "drupal/currency": "dev-custom#3223997-allow-php-8",

However when I clear the cache I get the following:

Fatal error: Uncaught Error: Interface "Commercie\Currency\CurrencyInterface" not found in /Users/passingphase/sites/mba_big/web/modules/contrib/currency/src/Entity/CurrencyInterface.php:12

This is proving hard to debug.

Update. Not found problem solved by directly mapping with the following entiry:

    "autoload": {
     "classmap": [
        "vendor/commercie/currency/*",
        "web/libraries/currency-exchange/*"
      ]
    },

Wildcards work!

christophedg’s picture

I'm sorry, but can you explain in more detail what you mean with this? :

Update. Not found problem solved by directly mapping with the following entiry:

"autoload": {
"classmap": [
"vendor/commercie/currency/*",
"web/libraries/currency-exchange/*"
]
},
Wildcards work!

Where do I add/change this? Thanks in advance.

vlad.dancer’s picture

Thanks kent@passingphase.nz, works for me I had additional issue with deploying mentioned composer packages on other envs.
Can't remember exact issue with composer, something like:

can't delete vendor/commercie/currency, no folder

I fixed it with next solution:

#delete "autoload" section in composer.json before the next command.
composer install
# revert deletions inside composer.json
git checkout composer.json
composer dump-autoload
drush cr

@ChristopheDG you need to place autoload settings in the root level of your composer.json file:

{
  ...
  "repositories": [...],
  "require": {...},
  "minimum-stability": "dev",
  "prefer-stable": true,
  "config": {...},
  "scripts": {...},
  "extra": {...},
  "autoload": {
    "classmap": [
      "vendor/commercie/currency/*",
      "docroot/libraries/currency-exchange/*"
    ]
  },
  "require-dev": {...}
}
bwoods’s picture

The info from kent@passingphase.nz was extremely useful in getting this to work locally. I made a few minor edits, mostly when testing my build and using https versus git directly. But I wanted to warn anyone with a CI/CD setup that the changes to autoload likely won't work unless you have the ability to rerun composer from your build. This seems like a bit of a chicken-and-egg problem with respect the directories being there versus being able to load properly. I guess I'll wait until some of this stuff is officially patched until moving forward with it.

kristen pol’s picture

Issue tags: -Drupal10 +Drupal 10

Fixing tag.

Berdir made their first commit to this issue’s fork.

berdir’s picture

Title: Allow PHP 8 » Allow PHP 8, Drupal 10 compatibility
Status: Reviewed & tested by the community » Needs review

Released updates for the depending libraries, including D10 compatibility in this MR.

berdir’s picture

Status: Needs review » Fixed

Merged.

  • Berdir committed 44c7426 on 8.x-3.x authored by tim.plunkett
    Issue #3223997 by tim.plunkett: Allow PHP 8, Drupal 10 compatibility
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.