deptrac
deptrac copied to clipboard
PHP Config: LayerCollector should reference layer by variable
Currently it is by the string representation of the layer name.
That's a good idea. But one disadvantage would be, that you have to define the LayerCollectorConfig add the end (should be fine with a note in the documentation), if you want to reference the other layers by the variable.
So should be have both options?
$secondLayer = Layer::withName('second')->collectors(
// by string
LayerConfig::create('first'),
);
$firstLayer = Layer::withName('first')->collectors(
DirectoryConfig::create('./src'),
);
$thirdLayer = Layer::withName('thirs')->collectors(
// by variable
LayerConfig::create($firstLayer),
);
Yeah, absolutely. What I like about this approach is that it would make it much harder to make cyclic layer dependencies. I have more notes on PHP Config ergonomics as I just ported a relatively large project from YAML to PHP in the past few days.