Skip to content

Cyclic

A dependency cycle occurs when a class depends on itself through its dependencies.

This situation violates the acyclic dependencies principle and can indicate poor design, leading to a group of components that are difficult to maintain and evolve.

First analysis

This command detects cyclic dependencies in the specified path.

php class-dependencies-analyzer cyclic <path>

Note

To obtain accurate results, it is crucial to analyze your entire codebase. If you perform a partial analysis, some nodes may appear incomplete.

Filtering results

To display only a list of namespaces, use the --only= option.

php class-dependencies-analyzer cyclic app --only='App\Domain,Infrastructure'

To exclude a list of namespaces, use the --exclude= option.

php class-dependencies-analyzer cyclic app --exclude='App\Models'