Search code examples
phppackagecomposer-phppackagist

Not able to install composer package


I'm trying to install my first composer package which I have built for learning.

For that, I have successfully setup Github repository and packagist account:

https://github.com/xparthx/Composer-package-demo

https://packagist.org/packages/xparthxvorax/demo

The issue is when I'm trying to install it using composer require xparthxvorax/demo, it gives me following error:

[UnexpectedValueException]
Error while installing xparthxvorax/demo, composer-plugin packages should have a class defined in their extra key to be usable.

I think the issue is with the package type. As per this doc, the default package type should be library:

https://getcomposer.org/doc/04-schema.md#type


Solution

  • Create a new tag, because with composer require composer will try to install latest tag, which in your case is the one with "composer-plugin" type: https://github.com/xparthx/Composer-package-demo/blob/v1/composer.json