'Interface "Composer\Plugin\PluginInterface" not found

I am writing composer package and in my plugin code I am trying to get Composer\Plugin\PluginInterface but I'm receiving Interface "Composer\Plugin\PluginInterface" not found when I install my package.

My plugin composer.json

{
    "name": "..../.....",
    "description": "....",
    "keywords": [
      //...
    ],
    "license": "MIT",
    "authors": [
      {
        "name": "...",
        "email": "...",
        "homepage": "...",
      }
    ],
    "type": "composer-plugin",
    "require": {
      "php": ">=8.0",
      "composer-plugin-api": "~2.0", <-- here
    },
    "autoload": {
      "psr-4": {
        "...\\....\\": "src/"
      }
    },
    "extra": {
      "class": "...\\....\\....",
      "laravel": {
          "providers": [
            "...\\....\\...."
          ]
      }
    }
}

And here is my plugin structure: (In case I forget to add something!)

<?php

namespace ...\....;

use Composer\Composer;
use Composer\EventDispatcher\EventSubscriberInterface;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface; <-- Not Found!
use Composer\Script\Event;
use Composer\Script\ScriptEvents;

class MyClassPlugin implements PluginInterface, EventSubscriberInterface
{
    public static function getSubscribedEvents(){}
    public static function update(){...}
    public static function myFunctionOne(){...}
    public static function myFunctionTwo(){...}
    public static function myFunctionThree(){...}
    public static function generateConfig(){...}
    public static function activate(){...}
    public static function deactivate(){...}
    public static function uninstall(){...}
}

Also this is my installed composer: Composer version 2.3.5

Any idea?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source