定制 componenta/composer-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

componenta/composer-plugin

Composer 安装命令:

composer require componenta/composer-plugin

包简介

Composer integration for generated Componenta package config providers

README 文档

README

Composer plugin that generates the list of Componenta package config providers installed in an application. Packages expose providers through Composer metadata, and this plugin writes a PHP file that the application config can load.

Use this package in application projects. Library packages should only declare their providers in extra.componenta.config-providers.

Installation

composer require componenta/composer-plugin

Composer must allow the plugin:

{
  "config": {
    "allow-plugins": {
      "componenta/composer-plugin": true
    }
  }
}

Package Boundary

The package does not load application configuration and does not build the DI container. It only reads Composer package metadata and generates a PHP file with provider class names.

Applications load that file explicitly, usually through Componenta\App\Config\ComposerPackageConfigProvider.

Package Metadata

A package exposes providers like this:

{
  "extra": {
    "componenta": {
      "config-providers": [
        "Componenta\\Http\\Router\\ConfigProvider"
      ]
    }
  }
}

The root project controls the generated file path:

{
  "extra": {
    "componenta": {
      "config-providers-file": "config/componenta-providers.php"
    }
  }
}

If no path is configured, the plugin uses config/componenta-providers.php.

Runtime Behavior

The plugin runs on Composer post-autoload-dump, post-install-cmd, and post-update-cmd events. It collects provider classes from the current installed package set and updates the generated file.

The file is written through a temporary file and rename(). Unchanged contents are not rewritten, and opcache_invalidate() is called after a successful replacement when OPcache is available.

The generated file returns an array of provider class names and should not be edited manually.

Public Classes

  • ComponentaPlugin is the Composer plugin entry point.
  • ProviderCollector reads installed packages.
  • ProviderExtractor reads provider metadata from package extra.
  • ProviderFileRenderer renders the PHP array.
  • ProviderFileWriter writes the generated file.

Related Packages

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固