开源技术社区/zend-component-installer

Composer插件,用于将模块和配置提供者注入到应用程序配置中

3.1.0 2020-12-30 09:06 UTC

README

Build Status Coverage Status

仓库已弃用,最后更新日期为2019年12月31日

此仓库已迁移至 laminas/laminas-component-installer

此仓库包含Composer插件类 Zend\ComponentInstaller\ComponentInstaller,该类为以下事件提供Composer事件钩子:

  • post-package-install
  • post-package-uninstall

通过Composer全局安装

要安装此实用工具以用于您使用的所有项目

$ composer global require zendframework/zend-component-installer

按项目安装

要安装此实用工具以用于已由composer管理的特定项目

$ composer require zendframework/zend-component-installer

编写使用安装程序的包

包可以通过在它们的composer.json文件中的extra.zf配置下定义以下键之一来选择加入来自zend-component-installer的工作流程:

"extra": {
  "zf": {
    "component": "Component\\Namespace",
    "config-provider": "Classname\\For\\ConfigProvider",
    "module": "Module\\Namespace"
  }
}
  • component是专门用于zend-mvc + zend-modulemanager的;与其关联的命名空间中必须存在一个Module类。此设置表示应注入到以下之一的应用程序模块列表顶部的低级别组件:

    • config/application.config.php
    • config/modules.config.php
    • config/development.config.php
  • module是专门用于zend-mvc + zend-modulemanager的;与其关联的命名空间中必须存在一个Module类。此设置表示应注入到以下之一的应用程序模块列表底部的用户或第三方模块:

    • config/application.config.php
    • config/modules.config.php
    • config/development.config.php
  • config-provider用于使用expressive-config-managerzend-config-aggregator(可能是或可能不是Expressive应用程序)的应用程序。列出的类必须是一个可调用的类,返回配置数组的数组,并将注入到以下之一的最顶部:

    • config/config.php

自动安装的包白名单

在项目级别,您可以通过标记暴露配置提供者和要自动注入的模块的包来通过component-whitelist键进行配置

"extra": {
  "zf": {
    "component-whitelist": [
      "zendframework/zend-expressive",
      "zendframework/zend-expressive-helpers"
    ]
  }
}

此配置必须在根包级别(消耗配置提供包的包)进行。