Neuronet
Neuronet

Reputation: 15

PHP class Interfaces in Composer packages

I use Composer for dependency management in my PHP project.

In a packageA I have ClassA. (file ClassA.php)

ClassA can use satellite classes, what implements SatelliteInterface.

SatelliteInterface defined in SateliteInterface.php

ClassB implements SatelliteInterface and provided in PackageB in the file ClassB.php.

ClassC implements SatelliteInterface and provided in PackageC in the file ClassC.php.

ClassB and ClassC can be used without ClassA.

In what package I need to put SateliteInterface.php file?

What dependencies of the packages will be?

Thank you.

Upvotes: 1

Views: 664

Answers (2)

Pierre
Pierre

Reputation: 884

I would put the SatelliteInterface into a separate Package D.

Package B and Package C would require Package D.

Package A doesn't require anything if I understand it right, but you could use "suggest" in your package A's composer.json to suggest package B and C.

Upvotes: 1

Sergiu Paraschiv
Sergiu Paraschiv

Reputation: 10153

Package A requires Package B and Package C.

Package B and Package C require a package containing SatelliteInterface.

Upvotes: 0

Related Questions