Reputation: 166076
I recently discovered that composer supports the concept of a virtual package. As I understand it virtual packages allow package developers to add an abstract/interface like package to their project's list of require
d modules. If someone wants to use a module with a virtual package dependency in your own project, you also need to require a second package that had the virtual package listed in its provides
section.
i.e. if a package has the virtual package php-http/client-implementation as a requirement, you'll also need to require in a package like php-http/guzzle6-adapter, which provides this package.
My Question: If I wanted to create a new virtual package, how would I do that? i.e. how does -- composer? packagist.org? know that php-http/client-implementation
is a virtual package? Did someone need to publish that package as virtual? Or are virtual packages somehow derived? If packagist is magically deriving them does that mean virtual packages won't work in non-packagist repositories?
Upvotes: 1
Views: 257
Reputation: 3764
Virtual packages are derived only because they are packages in which there is no physical package.
There is no way to straight up define them. Once you create a package that "provides" a virtual package, it will exist.
I believe the concept is visible as virtual packages only to help us all see how it is working. They should work with any type of repository as the require/provide directives are part of the composer software
Upvotes: 2