简体   繁体   English

Composer是否在ZF2中提供了Zend Loader的任何性能

[英]Does Composer provide any performance over Zend Loader in ZF2

ZF2 is using Composer for package management and distribution. ZF2正在使用Composer进行包管理和分发。 My question is that does it provide any performance boost over Zend Loader? 我的问题是它是否提供了超过Zend Loader的任何性能提升?

Firstly, Zend\\Loader is just namespace and presents multiple classes under the hood like Factories, Autoloaders, PluginLoaders, ModuleLoaders etc... So, Zend Loader !== Composer and comparing different concepts is generally wrong. 首先, Zend\\Loader只是命名空间,并提供了诸如Factories,Autoloaders,PluginLoaders,ModuleLoaders等引擎盖下的多个类......所以, Zend Loader !== Composer和比较不同的概念通​​常是错误的。

Second thing is, composer is not a "package manager" and you can use ZF2 without composer. 第二件事是,作曲家不是“包经理”,你可以在没有作曲家的情况下使用ZF2。 From the documentation : 文档

Composer is not a package manager. Composer不是包管理器。 Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory (eg vendor) inside your project. 是的,它处理“包”或库,但它在每个项目的基础上管理它们,将它们安装在项目内的目录(例如供应商)中。 By default it will never install anything globally. 默认情况下,它永远不会全局安装。 Thus, it is a dependency manager. 因此,它是一个依赖管理器。

Primary concern of the composer is providing easy dependency management between libraries, standardising autoloading process etc.. not performance. 作曲家的主要关注点是提供库之间的简单依赖管理,标准化自动加载过程等。而不是性能。 It also prepares an autoload file for your project for all of the classes in the 3rd party libraries which installed by composer. 它还为您的项目准备一个自动加载文件,用于由作曲家安装的第三方库中的所有类。 This makes our lives better. 这让我们的生活更美好。

On the other hand, the Zend Loader namespace and related classes. 另一方面,Zend Loader命名空间和相关的类。 This short summary from the official documentation is really straightforward: 官方文档中的这个简短摘要非常简单:

ZF2 employs multiple autoloading strategies; ZF2采用多种自动加载策略; as an example, you may have a class map for your most used classes, but want to use a PSR-0 style autoloader for 3rd party libraries. 例如,您可能拥有最常用类的类映射,但希望为第三方库使用PSR-0样式自动加载器。

A short-summary about the classes under the Zend Loader namespace: 关于Zend Loader命名空间下的类的简短摘要:

  • ClassMapAutoloader : It's designed with performance in mind. ClassMapAutoloader :它的设计考虑了性能。 Avoids unnecessary filesystem operations when autoloading. 自动加载时避免不必要的文件系统操作。
  • StandardAutoloader : It's a PSR-0-compliant autoloader. StandardAutoloader :它是符合PSR-0标准的自动加载器。 Assumes a 1:1 mapping of the namespace + classname to the filesystem. 假设命名空间+类名与文件系统的1:1映射。
  • ModuleAutolader : A special implementation of the Zend\\Loader\\SplAutoloader interface, used by Zend\\ModuleManager to autoload Module classes from different sources. ModuleAutolader :Zend \\ Loader \\ SplAutoloader接口的一个特殊实现,由Zend \\ ModuleManager用于自动加载来自不同源的模块类。
  • PluginClassLoader : Resolves plugin names -> to -> class names by providing a simple mechanism for aliasing plugin names to classnames for later retrieval. PluginClassLoader :通过提供一个简单的机制来将插件名称别名化为类名以便以后检索,从而解决插件名称 - >到 - >类名称。

So, if your main concern is filesystem-level performance, you should focus on classmap autoloading and opcode caching. 因此,如果您主要关心的是文件系统级性能,则应该关注类映射自动加载和操作码缓存。 There are lot of metrics which affects overall application performance and there are no silver bullet to boost performance. 有许多指标会影响整体应用程序性能 ,并且没有灵丹妙药来提升性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM