You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, it detects shadowed depencencies similar to [maglnet/composer-require-checker](https://github.com/maglnet/ComposerRequireChecker), but **much faster**:
*Note that this package itself has zero composer dependencies.*
19
+
17
20
## Usage:
18
21
19
22
```sh
20
-
composer dump-autoload -o# we use composer's autoloader to detect which class belongs to which package
21
-
vendor/bin/composer-dependency-analyser src
23
+
composer dump-autoload --classmap-authoritative# we use composer's autoloader to detect which class belongs to which package
24
+
vendor/bin/composer-dependency-analyser
22
25
```
23
26
24
27
Example output:
@@ -35,14 +38,27 @@ Found shadow dependencies!
35
38
36
39
You can add `--verbose` flag to see first usage of each class.
37
40
38
-
## Shadow dependency risks
39
-
You are not in control of dependencies of your dependencies, so your code can break if you rely on such transitive dependency and your direct dependency will be updated to newer version which does not require that transitive dependency anymore.
41
+
## What it does:
42
+
This tool reads your `composer.json` and scans all paths listed in both `autoload` sections while analysing:
43
+
44
+
- Shadowed dependencies
45
+
- Those are dependencies of your dependencies, which are not listed in `composer.json`
46
+
- Your code can break when your direct dependency gets updated to newer version which does not require that shadowed dependency anymore
47
+
- You should list all those classes within your dependencies
48
+
- Dev dependencies used in production code
49
+
- Your code can break once you run your application with `composer install --no-dev`
50
+
- You should move those to `require` from `require-dev`
51
+
- Unknown classes
52
+
- Any class missing in composer classmap gets reported as we cannot say if that one is shadowed or not
53
+
- This might be expected in some cases, so you can disable this behaviour by `--ignore-unknown-classes`
54
+
55
+
It is expected to run this tool in root of your project, where the `composer.json` is located.
56
+
If you want to run it elsewhere, you can use `--composer-json=path/to/composer.json` option.
40
57
41
-
Every used class should be listed in your `require` (or `require-dev`) section of `composer.json`.
58
+
Currently, it only supports those autoload sections: `psr-4`, `psr-0`, `files`.
42
59
43
60
## Future scope:
44
61
- Detecting dead dependencies
45
-
- Detecting dev dependencies used in production code
0 commit comments