-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce config builders for deptrac #978
Comments
To give an example, this is what the current deptrac.yaml would likely look like (I get differing output, so I might have made some mistakes, please double check) with PHP config without config builders:
Especially for layers it would make sense to have something that is easier to manage and having autocomplete for the keys and ideally for the type values as well. |
If no one else likes to start to work on this one, I would give it a try in the next few days. |
With this change it will be much more easy to work with big monorepos 👍 |
Could we just have possibility to inject custom layers resolver? Or get layers from own services? Qossmic\Deptrac\Core\Layer\LayerResolver:
factory: ['@My\Layer\Factory', 'create'] But this requires to know about all its dependencies inside a factory. So my method looks like public function create(CollectorResolverInterface $collectorResolver): LayerResolverInterface
{
$layers = //my logic to automatically build layers
return new LayerResolver($collectorResolver, $layers);
} I still pass Maybe it would be better to grab merge layers from config and or custom layer provider in something like $layers = [];
foreach ($this->layerProviders as $provider) {
$layers = array_merge($layers, $provider->getLayers());
} The default providers would read config from deptrac:
layer_providers:
- 'My\Layer\Provider' |
@ilnytskyi can you explain how the current ConfigBuilder is not sufficient? You can define layers dynamically in PHP now: Line 29 in a39d889
|
Implemented in #1002. |
@patrickkusebauch thanks for info! That should be sufficient. I will take a look. |
Yeah, we are lagging behind on the docs. It is a very recent addition. |
Background
In theory, it is already possible to use php instead of yaml for configuring deptrac. Unfortunately, because a lot of the configuration contains complex array structures, e.g. for defining layers and the collectors, this can be rather unwieldy.
Before, switching to PHP as default format, I would like to make configuration with php a bit easier. Symfony introduced config builder classes.
Task
Notes
initializeLayers
into the container, i.e. each layer represents its own service in the container. There is one case that will be hard to handle, when layers need to access other layers (e.g. layer resolver or bool resolver) and their ordering is important. If we can do it, it might make it easier to configure them, because we could replace the extension logic with simple service instantiation instead. This is just a vague idea, so it definitely needs some investigation and might be a follow up instead.The text was updated successfully, but these errors were encountered: