I am creating a WordPress plugin but need to connect to Xero's API. Xero suggest using the composer plugin xero-php-oauth2
so I setup my WP plugin to use composer, which works. And I have successfully installed and used phpdotenv
as a test.
Unfortunately I am getting the following error:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version "\>= 8.1.0". You are running 8.0.28. in /var/www/html/wp-content/plugins/tws-eta-api-visualisations/vendor/composer/platform_check.php on line 24
Composer seems to think that I my PHP version is 8.0.28
when I am running 8.1.17
and I cannot figure out why.
I am configuring both PHP and composer with a Nix flake:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
devShell = with pkgs; pkgs.mkShell {
buildInputs = [
php81
php81.packages.composer
nodejs-16_x
(yarn.override { nodejs = nodejs-16_x; })
];
shellHook = ''
if [ ! -d "vendor" ]; then
${php81}/bin/php ${php81.packages.composer}/libexec/composer/composer.phar update
composer install
fi
if [ ! -d "node_modules" ]; then
yarn install --immutable
fi
yarn build
open http://localhost:8000
'';
};
}
);
}
Does anyone know what I can do to resolve my flake?
I have tried following various guides online about setting Composer's PHP version via config updates, install commands, and composer.phar
.