如何检查 Symfony 中是否未使用库?
How to check if libraries are unused in Symfony?
我的 package.json 中列出了很多库,而且我知道其中大部分都未被使用。我怎么知道哪些是我用的,哪些是我不用的?
我正在使用 Symfony 3.4 和 Yarn 作为依赖管理器
谢谢!
如果你想知道为什么安装一个包,你可以运行命令why。例如,请参阅此列表:
>composer show
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
phpdocumentor/reflection-common 1.0.1 Common reflection classes used by
.....
input/output with nice error messages.
查看实例化包
>composer why doctrine/instantiator
phpspec/prophecy 1.8.0 requires doctrine/instantiator (^1.0.2)
phpunit/phpunit-mock-objects 2.3.8 requires doctrine/instantiator (^1.0.2)
你也可以试试树版:
>composer why -t doctrine/instantiator
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
├──phpspec/prophecy 1.8.0 (requires doctrine/instantiator ^1.0.2)
│ └──phpunit/phpunit 4.8.36 (requires phpspec/prophecy ^1.3.1)
│ └──XXXXXXXX dev-master (requires (for development) phpunit/phpunit ~4.6)
└──phpunit/phpunit-mock-objects 2.3.8 (requires doctrine/instantiator ^1.0.2)
└──phpunit/phpunit 4.8.36 (requires phpunit/phpunit-mock-objects ~2.3)
└──XXXXXXXX dev-master (requires (for development) phpunit/phpunit ~4.6)
在 Symfony 中,前端和后端依赖项由两个不同的系统分开保存。因此,可以使用两种不同的工具检测未使用的依赖项。以下工具只是一个示例,因为存在更多具有相同功能的工具。
前端: package.json
后端: composer.json
我的 package.json 中列出了很多库,而且我知道其中大部分都未被使用。我怎么知道哪些是我用的,哪些是我不用的?
我正在使用 Symfony 3.4 和 Yarn 作为依赖管理器
谢谢!
如果你想知道为什么安装一个包,你可以运行命令why。例如,请参阅此列表:
>composer show
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
phpdocumentor/reflection-common 1.0.1 Common reflection classes used by
.....
input/output with nice error messages.
查看实例化包
>composer why doctrine/instantiator
phpspec/prophecy 1.8.0 requires doctrine/instantiator (^1.0.2)
phpunit/phpunit-mock-objects 2.3.8 requires doctrine/instantiator (^1.0.2)
你也可以试试树版:
>composer why -t doctrine/instantiator
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
├──phpspec/prophecy 1.8.0 (requires doctrine/instantiator ^1.0.2)
│ └──phpunit/phpunit 4.8.36 (requires phpspec/prophecy ^1.3.1)
│ └──XXXXXXXX dev-master (requires (for development) phpunit/phpunit ~4.6)
└──phpunit/phpunit-mock-objects 2.3.8 (requires doctrine/instantiator ^1.0.2)
└──phpunit/phpunit 4.8.36 (requires phpunit/phpunit-mock-objects ~2.3)
└──XXXXXXXX dev-master (requires (for development) phpunit/phpunit ~4.6)
在 Symfony 中,前端和后端依赖项由两个不同的系统分开保存。因此,可以使用两种不同的工具检测未使用的依赖项。以下工具只是一个示例,因为存在更多具有相同功能的工具。
前端: package.json
后端: composer.json