composer dump-autoload - 命令

时间:2015-02-06 01:01:39

标签: composer-php

我不理解composer dump-autoload命令的描述:

If you need to update the autoloader because of new classes in a classmap package for example, you can use "dump-autoload" to do that without having to go through an install or update.
Additionally, it can dump an optimized autoloader that converts PSR-0/4 packages into classmap ones for performance reasons. In large applications with many classes, the autoloader can take up a substantial portion of every request's time. Using classmaps for everything is less convenient in development, but using this option you can still use PSR-0/4 for convenience and classmaps for performance. 

为什么会说dump ... for performance reasons?为什么要转储优化的加载器? 是因为性能原因而“倾销”还是“转换”?

如果是'倾销表现',为什么呢classmaps for performance

如果它'转换为性能',为什么然后转储自动加载器?

我很困惑。

2 个答案:

答案 0 :(得分:3)

它转储自动加载器使用的类映射。这样,自动加载器不需要搜索文件系统来查找正确的文件,它已经知道该文件。这样可以节省时间。

答案 1 :(得分:1)

在每种情况下,类图都不会更快。在生产中使用之前,请小心并衡量您从中获得的好处。

详情请参阅我的回答:Why use a PSR-0 or PSR-4 autoload in composer if classmap is actually faster?